示例#1
0
        public MemoryStream Execute(string[] commandLineArguments, MemoryStream ms = null)
        {
#if NET40
            var executable = Path.GetFileNameWithoutExtension(new Uri(typeof(HelpCommand).Assembly.CodeBase).LocalPath);
#else
            var executable = Path.GetFileNameWithoutExtension(new Uri(typeof(HelpCommand).GetTypeInfo().Assembly.CodeBase).LocalPath);
#endif

            var commandName = commandLineArguments.FirstOrDefault();

            if (string.IsNullOrEmpty(commandName))
            {
                PrintGeneralHelp(executable);
            }
            else
            {
                var commandMeta = commands.Find(commandName);
                if (commandMeta == null)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Command '{0}' is not supported", commandName);
                    Console.ResetColor();
                    PrintGeneralHelp(executable);
                }
                else
                {
                    var command = commands.Create(commandMeta);
                    PrintCommandHelp(executable, command, commandMeta, commandName);
                }
            }

            return(null);
        }