2024-07-02 22:22:50 -07:00
|
|
|
import 'package:libac_dart/argparse/Args.dart';
|
|
|
|
import 'package:libac_dart/argparse/Builder.dart';
|
|
|
|
import 'package:libac_dart/argparse/CLIHelper.dart';
|
|
|
|
import 'package:libac_dart/argparse/types/Bool.dart';
|
|
|
|
import 'package:libac_dart/argparse/types/String.dart';
|
|
|
|
import 'package:test/expect.dart';
|
|
|
|
import 'package:test/scaffolding.dart';
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
test("Test parsing a argument", () async {
|
2024-07-08 22:25:54 -07:00
|
|
|
List<String> testArgs = ["--test=12", "--enable", "--put=Here"];
|
2024-07-02 22:22:50 -07:00
|
|
|
|
|
|
|
Arguments defaults = Arguments();
|
|
|
|
|
|
|
|
Arguments parsed = await CLIHelper.parseArgs(testArgs, defaults);
|
|
|
|
|
|
|
|
expect(true, parsed.hasArg("test"));
|
|
|
|
expect(12, parsed.getArg("test")!.getValue() as int);
|
|
|
|
expect(ArgumentType.INTEGER, parsed.getArg("test")!.getType());
|
|
|
|
|
|
|
|
expect(true, parsed.hasArg("enable"));
|
|
|
|
expect(ArgumentType.BOOL, parsed.getArg("enable")!.getType());
|
|
|
|
|
|
|
|
expect("Here", parsed.getArg("put")!.getValue() as String);
|
|
|
|
});
|
|
|
|
|
|
|
|
test("Test printing Usage", () async {
|
|
|
|
Arguments testArgs = ArgumentsBuilder.builder()
|
|
|
|
.withArgument(BoolArgument(
|
|
|
|
name: "use_legacy", description: "Uses legacy settings"))
|
|
|
|
.withArgument(StringArgument(
|
|
|
|
name: "output",
|
|
|
|
value: "./out",
|
|
|
|
description: "Where to put the output files"))
|
|
|
|
.build();
|
|
|
|
|
|
|
|
String usage = CLIHelper.makeArgCLIHelp(testArgs);
|
|
|
|
print("LibAC_Dart\nTestsuite - 1.0\n\n${usage}");
|
|
|
|
});
|
|
|
|
}
|