예제 #1
0
파일: Xe.cs 프로젝트: yunhuios/xenadmin
 public static void debug(string msg, thinCLIProtocol tCLIprotocol)
 {
     if (tCLIprotocol.conf.debug)
     {
         Console.WriteLine("Debug: " + msg);
     }
 }
예제 #2
0
 private static void Debug(string msg, thinCLIProtocol tCliProtocol)
 {
     if (tCliProtocol.conf.debug)
     {
         Console.WriteLine("Debug: " + msg);
     }
 }
예제 #3
0
파일: Xe.cs 프로젝트: yunhuios/xenadmin
        public static void Main(string[] args)
        {
            thinCLIProtocol tCLIprotocol = new thinCLIProtocol(new delegateGlobalError(Global.error), new delegateGlobalUsage(Global.usage),
                                                               new delegateGlobalDebug(Global.debug), new delegateConsoleWrite(delegate(string s) { Console.Write(s); }),
                                                               new delegateConsoleWriteLine(delegate(string s) { Console.WriteLine(s); }),
                                                               new delegateConsoleReadLine(delegate { return(Console.ReadLine()); }),
                                                               new delegateExit(delegate(int i) { Environment.Exit(i); }),
                                                               new delegateProgress(delegate(int i) {}),
                                                               new Config());

            String body = "";

            Char[] eqsep = { '=' };
            for (int i = 0; i < args.Length; i++)
            {
                String s = args[i];
                try
                {
                    if (s.StartsWith("server"))
                    {
                        tCLIprotocol.conf.hostname = (s.Split(eqsep))[1];
                    }
                    else if (s.Equals("-s"))
                    {
                        tCLIprotocol.conf.hostname = args[++i];
                    }
                    else if (s.Equals("-u"))
                    {
                        tCLIprotocol.conf.username = args[++i];
                    }
                    else if (s.Equals("-pw"))
                    {
                        tCLIprotocol.conf.password = args[++i];
                    }
                    else if (s.Equals("-p"))
                    {
                        tCLIprotocol.conf.port = Int32.Parse(args[++i]);
                    }
                    else if (s.Equals("--nossl"))
                    {
                        tCLIprotocol.conf.nossl = true;
                    }
                    else if (s.Equals("-debug"))
                    {
                        tCLIprotocol.conf.debug = true;
                    }
                    else if (s.Equals("-version"))
                    {
                        Console.WriteLine("ThinCLI protocol: " + tCLIprotocol.major + "." + tCLIprotocol.minor);
                        Environment.Exit(0);
                    }
                    else
                    {
                        body += s + "\n";
                    }
                }
                catch {
                    Global.error("Failed to parse command-line arguments");
                    Global.usage();
                    Environment.Exit(1);
                }
            }
            if (tCLIprotocol.conf.hostname.Equals(""))
            {
                Global.error("No hostname was specified.");
                Global.usage();
                Environment.Exit(1);
            }
            Messages.performCommand(body, tCLIprotocol);
        }
예제 #4
0
        public static void Main(string[] args)
        {
            var tCliProtocol = new thinCLIProtocol(Error, Usage, Debug,
                                                   Console.Write, Console.WriteLine, Console.ReadLine,
                                                   Environment.Exit, i => { }, new Config());

            string body = "";

            char[] eqsep = { '=' };

            for (int i = 0; i < args.Length; i++)
            {
                string s = args[i];
                try
                {
                    if (s.StartsWith("server"))
                    {
                        tCliProtocol.conf.hostname = s.Split(eqsep)[1];
                    }
                    else if (s.Equals("-s"))
                    {
                        tCliProtocol.conf.hostname = args[++i];
                    }
                    else if (s.Equals("-u"))
                    {
                        tCliProtocol.conf.username = args[++i];
                    }
                    else if (s.Equals("-pw"))
                    {
                        tCliProtocol.conf.password = args[++i];
                    }
                    else if (s.Equals("-p"))
                    {
                        tCliProtocol.conf.port = Int32.Parse(args[++i]);
                    }
                    else if (s.Equals("--nossl"))
                    {
                        tCliProtocol.conf.nossl = true;
                    }
                    else if (s.Equals("-debug"))
                    {
                        tCliProtocol.conf.debug = true;
                    }
                    else if (s.Equals("-version"))
                    {
                        Console.WriteLine("ThinCLI protocol: " + tCliProtocol.major + "." + tCliProtocol.minor);
                        Environment.Exit(0);
                    }
                    else
                    {
                        body += s + "\n";
                    }
                }
                catch
                {
                    Error("Failed to parse command-line arguments");
                    Usage();
                    Environment.Exit(1);
                }
            }

            if (tCliProtocol.conf.hostname.Equals(""))
            {
                Error("No hostname was specified.");
                Usage();
                Environment.Exit(1);
            }

            Messages.performCommand(body, tCliProtocol);
        }
예제 #5
0
        public static void Main(string[] args)
        {
            thinCLIProtocol tCLIprotocol = new thinCLIProtocol(new delegateGlobalError(Global.error), new delegateGlobalUsage(Global.usage),
                                                               new delegateGlobalDebug(Global.debug), new delegateConsoleWrite(delegate(string s) { Console.Write(s); }),
                                                               new delegateConsoleWriteLine(delegate(string s) { Console.WriteLine(s); }),
                                                               new delegateConsoleReadLine(delegate { return(Console.ReadLine()); }),
                                                               new delegateExit(delegate(int i) { Environment.Exit(i); }),
                                                               new delegateProgress(delegate(int i) {}),
                                                               new Config());

            String body = "";

            Char[] eqsep = { '=' };

            bool isDisplayConfig = false;

            string temp = Environment.GetEnvironmentVariable("XE_HOST");

            if (temp != null)
            {
                tCLIprotocol.conf.hostname = temp;
            }

            temp = Environment.GetEnvironmentVariable("XE_USERNAME");
            if (temp != null)
            {
                tCLIprotocol.conf.username = temp;
            }

            temp = Environment.GetEnvironmentVariable("XE_PASSWORD");
            if (temp != null)
            {
                tCLIprotocol.conf.password = temp;
            }

            temp = Environment.GetEnvironmentVariable("XE_PORT");
            if (temp != null)
            {
                tCLIprotocol.conf.port = Int32.Parse(temp);
            }

            for (int i = 0; i < args.Length; i++)
            {
                String s = args[i];
                try
                {
                    if (s.StartsWith("server"))
                    {
                        tCLIprotocol.conf.hostname = (s.Split(eqsep))[1];
                    }
                    else if (s.Equals("-s"))
                    {
                        tCLIprotocol.conf.hostname = args[++i];
                    }
                    else if (s.Equals("-u"))
                    {
                        tCLIprotocol.conf.username = args[++i];
                    }
                    else if (s.Equals("-pw"))
                    {
                        tCLIprotocol.conf.password = args[++i];
                    }
                    else if (s.Equals("-p"))
                    {
                        tCLIprotocol.conf.port = Int32.Parse(args[++i]);
                    }
                    else if (s.Equals("--nossl"))
                    {
                        tCLIprotocol.conf.nossl = true;
                    }
                    else if (s.Equals("-debug"))
                    {
                        tCLIprotocol.conf.debug = true;
                    }
                    else if (s.Equals("-display-config"))
                    {
                        isDisplayConfig = true;
                    }
                    else if (s.Equals("-h"))
                    {
                        Global.usage();
                        Environment.Exit(0);
                    }
                    else if (s.Equals("-version"))
                    {
                        Console.WriteLine("ThinCLI protocol: " + tCLIprotocol.major + "." + tCLIprotocol.minor);
                        Environment.Exit(0);
                    }
                    else
                    {
                        body += s + "\n";
                    }
                }
                catch {
                    Global.error("Failed to parse command-line arguments");
                    Global.usage();
                    Environment.Exit(1);
                }
            }
            if (tCLIprotocol.conf.hostname.Equals(""))
            {
                Global.error("No hostname was specified.");
                Global.usage();
                Environment.Exit(1);
            }

            if (isDisplayConfig)
            {
                Console.WriteLine("Host : " + tCLIprotocol.conf.hostname);
                Console.WriteLine("Username : "******"Password : "******"".PadRight(tCLIprotocol.conf.password.Length, '*'));
            }

            Messages.performCommand(body, tCLIprotocol);
        }
예제 #6
0
파일: Xe.cs 프로젝트: ReSalles/xenadmin
 public static void debug(string msg, thinCLIProtocol tCLIprotocol)
 {
     if (tCLIprotocol.conf.debug)
         Console.WriteLine("Debug: " + msg);
 }