generalLibraryCli function
Implementation
Future<void> generalLibraryCli({
required List<String> argsRaw,
}) async {
final Args args = Args(argsRaw);
final GeneralLibraryApi generalLibraryApi = GeneralLibraryApi();
bool isInteractive = true;
if (Platform.environment["no_interactive"] == "true") {
isInteractive = false;
}
String command = (args.arguments.firstOrNull ?? "").toLowerCase();
List<String> commands = [
"init",
"setup",
];
commands.sort();
if (commands.contains(command) == false) {
if (isInteractive) {
command = logger.chooseOne(
"Pilih",
choices: commands,
display: (choice) {
return choice.toUpperCaseFirstData();
},
);
} else {
print("Please use command: ${commands.join("\n")}");
exit(1);
}
}
if (command == "init") {
await generalLibraryApi
.create(newName: ".", directoryBase: Directory.current)
.listen((event) {
printed(event);
}).asFuture();
exit(0);
}
if (command == "setup") {
await generalLibraryApi
.setup(directoryBase: Directory.current)
.listen((event) {
printed(event);
}).asFuture();
exit(0);
}
print("not implemented");
exit(0);
}