using method

Implementation

CommandDefinitionBuilder using(File file) {
  final String stringContent = file.readAsStringSync();
  final content = switch (file.path) {
    final String path when path.contains('.json') =>
      jsonDecode(stringContent),
    final String path when path.contains('.yaml') =>
      (loadYaml(stringContent) as YamlMap).toMap(),
    _ => throw Exception('File type not supported')
  };

  _declareCommand(content);
  _declareGroups(content);
  _declareSubCommands(content);

  return this;
}