public override void Execute(IEnumerable <string> args) { var showHelp = false; var input = new OptionSet { { "h|?|help", value => showHelp = true }, { "x|experimental", value => Log.EnableExperimental = true }, { "anim", value => Log.EnableAnimation = true }, { "no-anim", value => Log.EnableAnimation = false }, { "trace", value => Log.EnableTrace = true }, { "v", value => Log.Level++ } }.Parse(args); // Implicit help when no input if (input.Count == 0) { Help(input); return; } var cmdName = input.First(); var cmd = _commands.FirstOrDefault(value => value.Name == cmdName); // Fuzzy COMMAND finder if (cmd == null && !string.IsNullOrEmpty(cmdName) && cmdName[0] != '-') { foreach (var c in _commands) { if ((!c.IsExperimental || Log.EnableExperimental) && c.Name.StartsWith(cmdName, StringComparison.InvariantCulture)) { if (cmd != null) { cmd = null; break; } cmd = c; } } } if (cmd == null) { var showVersion = false; var showCmdRef = false; new OptionSet { { "version", value => showVersion = true }, { "cmd-ref", value => showCmdRef = true } }.Parse(input); if (showVersion) { WriteProductInfo(); return; } if (showCmdRef) { WritePage(); foreach (var e in _commands.Where(value => value.Description != null)) { WritePage(e.Name, "--help"); } return; } var thing = cmdName.StartsWith('-') ? "option" : "command"; throw new ArgumentException(cmdName.Quote() + $" is not a valid {thing} -- see \"uno --help\" for a list of {thing}s"); } if (showHelp) { cmd.Help(input.Skip(1)); } else { cmd.Execute(input.Skip(1)); } ExitCode = cmd.ExitCode ?? Log.ErrorCount; }