/// <summary> /// Create an instance of the main application container. /// </summary> public App( IConsole console, IEnumerable <ICliModule> modules, IArgParser argParser, ILoggerConfigurationSource loggerConfigurationSource, IAppProgressTracker appProgressTracker) { _console = console; _modules = modules; _argParser = argParser; _loggerConfigurationSource = loggerConfigurationSource; _appProgressTracker = appProgressTracker; }
public async Task Parse(Stack <string> args) { if (args.Count == 0) { args.Push("-h"); } while (args.Count > 0) { string currentArgument = args.Pop(); IArgParser parser = _argFactory[currentArgument]; if (parser == null) { StringBuilder helpBuilder = new StringBuilder() .AppendLine($"Argument '{currentArgument}' is not recognized! Try:") .AppendLine() .AppendLine(" boxer script --help"); throw new ArgNotFoundException(helpBuilder.ToString()); } if (parser is HelpArgParser) { parser.Parse("Boxer.Args.ScriptArgs.IScriptArg;Boxer.Args.Verbs.ScriptVerb"); return; } if (args.Count == 0) { throw new ArgNotFoundException($"Parameter for argument '{currentArgument}' not found!{Environment.NewLine}"); } _scripts.AddRange(parser.Parse(args.Pop())); } await _sandboxHandler.HandleAsync(new SandboxRequest(_scripts)); }
public async Task Parse(Stack <string> args) { while (args.Count > 0) { string currentArgument = args.Pop(); IArgParser parser = _argFactory[currentArgument]; if (parser == null) { throw new ArgumentException("Unrecognized argument!", currentArgument); } if (parser is HelpArgParser) { parser.Parse("Boxer.Args.ScriptArgs.IScriptArg;Boxer.Args.Verbs.ScriptVerb"); return; } _scripts.AddRange(parser.Parse(args.Pop())); } await _sandboxHandler.HandleAsync(new SandboxRequest(_scripts)); }
public Task Parse(Stack <string> args) { string currentArgument = args != null && args.Count > 0 ? args.Pop() : null; if (currentArgument != null) { IArgParser parser = _argFactory[currentArgument]; if (parser is HelpArgParser) { var commandVerb = new VersionVerb(); StringBuilder helpBuilder = new StringBuilder() .AppendLine("COMMAND") .AppendLine($" {commandVerb.Name.First()} - {commandVerb.Help}"); Console.WriteLine(helpBuilder); return(Task.CompletedTask); } else { StringBuilder helpBuilder = new StringBuilder() .AppendLine($"Argument '{currentArgument}' is not recognized! Try:") .AppendLine() .AppendLine(" boxer version --help"); throw new ArgNotFoundException(helpBuilder.ToString()); } } string version = Assembly.GetEntryAssembly().GetName().Version.ToString(); Console.WriteLine(version); return(Task.CompletedTask); }