run method
Runs this command.
The return value is wrapped in a Future if necessary and returned by
CommandRunner.runCommand.
Implementation
@override
Future<int> run() async {
if (argResults!.rest.isEmpty) {
logger.err('Branch name is required.');
return ExitCode.usage.code;
}
final branchName = argResults!.rest.first;
logger.info('Checking out new branch: $branchName');
final result = await Process.run('git', ['checkout', '-b', branchName]);
if (result.exitCode != 0) {
logger.err(result.stderr as String);
return result.exitCode;
}
logger.success('Switched to branch $branchName');
return ExitCode.success.code;
}