ShowCliHelp() public static method

Display the command line options and then exit.
public static ShowCliHelp ( OptionSet options, Assembly thisAssembly ) : void
options OptionSet
thisAssembly System.Reflection.Assembly
return void
示例#1
0
文件: Client.cs 项目: jonocodes/mybox
        /// <summary>
        /// Handle command line args
        /// </summary>
        /// <param name="args"></param>
        public static void Main(string[] args)
        {
            OptionSet options = new OptionSet();

            String configDir = ClientServerConnection.DefaultConfigDir;

            options.Add("c|configdir=", "configuration directory (default=" + configDir + ")", delegate(string v) {
                configDir = Common.EndDirWithSlash(v);
            });

            options.Add("h|help", "show help screen", delegate(string v) {
                Common.ShowCliHelp(options, System.Reflection.Assembly.GetExecutingAssembly());
            });

            options.Add("v|version", "print the Mybox version", delegate(string v) {
                Console.WriteLine(Common.AppVersion);
                System.Diagnostics.Process.GetCurrentProcess().Kill();
            });


            // Note: all additional arguments are invalid since it does not take non-options

            List <string> extra = new List <string>();

            try {
                extra = options.Parse(args);
            }
            catch (OptionException) {
                Console.WriteLine("Invalid argument entered");

                // print the help screen
                Common.ShowCliHelp(options, System.Reflection.Assembly.GetExecutingAssembly());
            }

            if (extra.Count > 0)
            {
                Console.WriteLine("Invalid argument entered");

                // print the help screen
                Common.ShowCliHelp(options, System.Reflection.Assembly.GetExecutingAssembly());
            }


            new Client(configDir);
        }