public CommandRun BuildRun(IEnumerable <string> args) { if (!args.Any()) { if (DefaultCommand == null) { return(HelpRun(new Queue <string>())); } } args = ArgPreprocessor.Process(args); var queue = new Queue <string>(args); if (queue.Count == 0 && DefaultCommand != null) { return(buildRun(queue, CommandNameFor(DefaultCommand))); } var firstArg = queue.Peek().ToLowerInvariant(); if (firstArg == "dump-usages") { queue.Dequeue(); return(dumpUsagesRun(queue)); } if (_helpCommands.Contains(firstArg)) { queue.Dequeue(); return(HelpRun(queue)); } if (_commandTypes.Has(firstArg)) { queue.Dequeue(); return(buildRun(queue, firstArg)); } if (DefaultCommand != null) { return(buildRun(queue, CommandNameFor(DefaultCommand))); } else { return(InvalidCommandRun(firstArg)); } }
public void should_split_multi_args() { ArgPreprocessor.Process(new[] { "-abc" }).ShouldHaveTheSameElementsAs("-a", "-b", "-c"); }
public void should_support_multiple_types_of_flags() { ArgPreprocessor.Process(new[] { "-abc", "--xyz", "b" }).ShouldHaveTheSameElementsAs("-a", "-b", "-c", "--xyz", "b"); }
public void should_ignore_long_flag_args() { ArgPreprocessor.Process(new[] { "--abc" }).ShouldHaveTheSameElementsAs("--abc"); }
public void combined_short_flags_should_be_case_sensitive() { ArgPreprocessor.Process(new[] { "-aAbBcC" }).ShouldHaveTheSameElementsAs("-a", "-A", "-b", "-B", "-c", "-C"); }