run method
Runs this command.
The return value is wrapped in a Future if necessary and returned by
CommandRunner.runCommand.
Implementation
@override
void run() async {
try {
// Get project name for context first
final argMorphemeYaml = argResults.getOptionMorphemeYaml();
final projectName = YamlHelper.loadFileYaml(argMorphemeYaml).projectName;
// Initialize services with dependency injection
_initializeServices(projectName);
// Execute command through processor
final success = await _commandProcessor.execute(
argResults: argResults,
projectName: projectName,
);
// Report final result
if (success) {
StatusHelper.success('morpheme json2dart');
} else {
StatusHelper.failed('json2dart command failed');
}
} catch (e, stackTrace) {
StatusHelper.failed('Json2Dart command error: $e');
// Print stack trace in debug mode
if (argResults?['verbose'] == true) {
StatusHelper.failed('Stack trace: $stackTrace');
}
}
}