/// <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 #2
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);
            }
        }