public ParseResult Exec(RunningContext context) { string text = HelpTextGenerator.GetHelpMessage(_rootOptions, _options.Command); _rootOptions.CurrentSubCommand = CommandType.Help; Console.WriteLine(text); return(ParseResult.SuccessResult); }
public ExportCommand(Options options, CommandContext context) { _options = options.ExportCommand; if (_options.IsHelp) { _helpMessage = HelpTextGenerator.GetHelpMessage(options, "export"); } else { options.MetadataCommand = _options; _metadataCommand = new MetadataCommand(options, context); } }
private static ParseResult TryGetOptions(string[] args, out Options options) { options = new Options(); string invokedVerb = null; object invokedVerbInstance = null; if (args.Length == 0) { return(ParseResult.SuccessResult); } if (!Parser.Default.ParseArguments(args, options, (s, o) => { invokedVerb = s; invokedVerbInstance = o; })) { if (!Parser.Default.ParseArguments(args, options)) { var text = HelpTextGenerator.GetHelpMessage(options); return(new ParseResult(ResultLevel.Error, text)); } else { return(ParseResult.SuccessResult); } } else { try { options.CurrentSubCommand = (CommandType)Enum.Parse(typeof(CommandType), invokedVerb, true); } catch { return(new ParseResult(ResultLevel.Error, $"{invokedVerb} subcommand is not currently supported.")); } } return(ParseResult.SuccessResult); }
public BuildCommand(Options options, CommandContext context) { var buildCommandOptions = options.BuildCommand; if (buildCommandOptions.IsHelp) { _helpMessage = HelpTextGenerator.GetHelpMessage(options, "build"); } else { Config = MergeConfig(GetConfigFromOptions(buildCommandOptions), context); } if (!string.IsNullOrWhiteSpace(buildCommandOptions.Log)) { Logger.RegisterListener(new ReportLogListener(buildCommandOptions.Log)); } if (buildCommandOptions.LogLevel.HasValue) { Logger.LogLevelThreshold = buildCommandOptions.LogLevel.Value; } }
public MetadataCommand(Options options, CommandContext context) { var metadataCommandOptions = options.MetadataCommand; if (metadataCommandOptions.IsHelp) { _helpMessage = HelpTextGenerator.GetHelpMessage(options, "metadata"); } else { Config = MergeConfig(GetConfigFromOptions(metadataCommandOptions), context); InputModels = GetInputModels(Config); } if (!string.IsNullOrWhiteSpace(metadataCommandOptions.Log)) { Logger.RegisterListener(new ReportLogListener(metadataCommandOptions.Log)); } if (metadataCommandOptions.LogLevel.HasValue) { Logger.LogLevelThreshold = metadataCommandOptions.LogLevel.Value; } }