Beispiel #1
0
        /// <exception cref="System.IO.IOException"/>
        public virtual int Run(string[] args)
        {
            if (args.Length == 0)
            {
                AdminHelper.PrintUsage(false, "cacheadmin", Commands);
                return(1);
            }
            AdminHelper.Command command = AdminHelper.DetermineCommand(args[0], Commands);
            if (command == null)
            {
                System.Console.Error.WriteLine("Can't understand command '" + args[0] + "'");
                if (!args[0].StartsWith("-"))
                {
                    System.Console.Error.WriteLine("Command names must start with dashes.");
                }
                AdminHelper.PrintUsage(false, "cacheadmin", Commands);
                return(1);
            }
            IList <string> argsList = new List <string>();

            for (int j = 1; j < args.Length; j++)
            {
                argsList.AddItem(args[j]);
            }
            try
            {
                return(command.Run(GetConf(), argsList));
            }
            catch (ArgumentException e)
            {
                System.Console.Error.WriteLine(AdminHelper.PrettifyException(e));
                return(-1);
            }
        }
        /// <exception cref="System.Exception"/>
        public virtual int Run(string[] args)
        {
            if (args.Length == 0)
            {
                AdminHelper.PrintUsage(false, "storagepolicies", Commands);
                return(1);
            }
            AdminHelper.Command command = AdminHelper.DetermineCommand(args[0], Commands);
            if (command == null)
            {
                System.Console.Error.WriteLine("Can't understand command '" + args[0] + "'");
                if (!args[0].StartsWith("-"))
                {
                    System.Console.Error.WriteLine("Command names must start with dashes.");
                }
                AdminHelper.PrintUsage(false, "storagepolicies", Commands);
                return(1);
            }
            IList <string> argsList = new List <string>();

            Sharpen.Collections.AddAll(argsList, Arrays.AsList(args).SubList(1, args.Length));
            try
            {
                return(command.Run(GetConf(), argsList));
            }
            catch (ArgumentException e)
            {
                System.Console.Error.WriteLine(AdminHelper.PrettifyException(e));
                return(-1);
            }
        }
Beispiel #3
0
            /// <exception cref="System.IO.IOException"/>
            public virtual int Run(Configuration conf, IList <string> args)
            {
                if (args.Count == 0)
                {
                    foreach (AdminHelper.Command command in commands)
                    {
                        System.Console.Error.WriteLine(command.GetLongUsage());
                    }
                    return(0);
                }
                if (args.Count != 1)
                {
                    System.Console.Out.WriteLine("You must give exactly one argument to -help.");
                    return(0);
                }
                string commandName = args[0];

                // prepend a dash to match against the command names
                AdminHelper.Command command_1 = AdminHelper.DetermineCommand("-" + commandName, commands
                                                                             );
                if (command_1 == null)
                {
                    System.Console.Error.Write("Unknown command '" + commandName + "'.\n");
                    System.Console.Error.Write("Valid help command names are:\n");
                    string separator = string.Empty;
                    foreach (AdminHelper.Command c in commands)
                    {
                        System.Console.Error.Write(separator + Sharpen.Runtime.Substring(c.GetName(), 1));
                        separator = ", ";
                    }
                    System.Console.Error.Write("\n");
                    return(1);
                }
                System.Console.Error.Write(command_1.GetLongUsage());
                return(0);
            }