execute method
execute command
Implementation
@override
Future<void> execute() async {
var isProject = false;
if (GetCli.arguments[0] == 'create') {
isProject = GetCli.arguments[1].split(':').first == 'project';
}
var name = this.name;
if (name.isEmpty || isProject) {
name = 'home';
}
var newFileModel =
Structure.model(name, 'screen', true, on: onCommand, folderName: name);
var pathSplit = Structure.safeSplitPath(newFileModel.path!);
pathSplit.removeLast();
var path = pathSplit.join('/');
path = Structure.replaceAsExpected(path: path);
if (Directory(path).existsSync()) {
final menu = Menu([
LocaleKeys.options_yes.tr,
LocaleKeys.options_no.tr,
], title: LocaleKeys.ask_existing_page.trArgs([name]).toString());
final result = menu.choose();
if (result.index == 0) {
_writeFiles(path, name, overwrite: true);
}
} else {
Directory(path).createSync(recursive: true);
_writeFiles(path, name);
}
}