import 'dart:async'; import 'dart:io'; import 'package:dart_framework/charset/euc_kr.dart'; import 'package:oto_cli/cli/cli.dart'; import 'package:oto_cli/cli/commands/command_base.dart'; import 'package:dart_framework/utils/system_util.dart'; import 'package:oto_cli/oto/application.dart'; class CommandExe extends CommandBase { @override Map> get arguments => { '-j': ["Used when it's a Jenkins build."], '-t': ["This is the setup for testing."], '-f {file path}': ["Run the yaml file to process."] }; @override String get name => 'exe'; @override Future execute(List parameters) { for (var i = 0; i < parameters.length; ++i) { var item = parameters[i]; if (item.startsWith('-j')) { Application.instance.build(BuildType.jenkins); break; } if (item.startsWith('-t')) { Application.instance.build(BuildType.test); } if (item.startsWith('-f')) { var file = ''; if (parameters.length > i + 1) { file = parameters[i + 1]; } else { file = item.replaceFirst('-f', '').trimLeft(); } startYaml(file); break; } } return simpleFuture; } void startYaml(String target) { var file = File(target); if (file.existsSync()) { Application.instance.build(BuildType.file, yamlContent: file.readAsStringSync( encoding: Platform.isWindows ? eucKr : systemEncoding)); } else { CLI.print([ CLI.style('There are no files in path "$target"', color: Color.red) ]); } } @override String getDescription() { return ':::: Read documents written in yaml to do process task.'; } }