Example #1
0
        public static int Main(string[] args)
        {
            try
            {
                args = ExpandArgs(args);

                if (args.Length == 0)
                {
                    ShowHelp();

                    return(-1);
                }

                string commandName = args[0];

                Type commandType = CommandHelpers.GetCommandType(commandName);

                if (commandType == null)
                {
                    ShowHelp();

                    return(-1);
                }

                var command = (ICommand)Activator.CreateInstance(commandType);

                return(command.Run(new List <string>(args).GetRange(1, args.Length - 1).ToArray()));
            }
            catch (Exception e)
            {
                Console.WriteLine("Unexpected error: {0}", e.Message);
            }

            return(-1);
        }
Example #2
0
        public int Run(string[] args)
        {
            if (args.Length == 0)
            {
                Program.ShowHelp();

                return(0);
            }

            string commandName = args[0];

            Type commandType = CommandHelpers.GetCommandType(commandName);

            if (commandType == null)
            {
                Program.ShowHelp();

                return(-1);
            }

            CommandHelpers.WriteHelp(commandType);

            return(0);
        }