Пример #1
0
        static bool Passwd(IList <string> unparsed)
        {
            if (unparsed.Count != 0)
            {
                Console.Error.WriteLine("Too many arguments for [change_password]: {0}", String.Join(", ", unparsed.Select(s => String.Format("'{0}'", s))));
                Console.Error.WriteLine("Usage: vmc passwd"); // TODO usage statement standardization
                return(false);
            }

            IVcapClient      vc   = new VcapClient();
            VcapClientResult rslt = vc.Info();
            Info             info = rslt.GetResponseMessage <Info>();

            Console.WriteLine("Changing password for '{0}'", info.User);

            Console.Write("New Password: "******"Verify Password: "******"Passwords did not match!");
                return(false);
            }
        }
Пример #2
0
        static bool Info(IList <string> unparsed)
        {
            // TODO match ruby argument parsing
            if (unparsed.Count != 0)
            {
                Console.Error.WriteLine("Usage: vmc info"); // TODO usage statement standardization
                return(false);
            }

            IVcapClient      vc   = new VcapClient();
            VcapClientResult rslt = vc.Info();

            if (rslt.Success)
            {
                var info = rslt.GetResponseMessage <Info>();
                if (result_as_json || result_as_rawjson)
                {
                    if (result_as_rawjson)
                    {
                        Console.WriteLine(info.RawJson);
                    }
                    if (result_as_json)
                    {
                        Console.WriteLine(JsonConvert.SerializeObject(info, Formatting.Indented));
                    }
                }
                else
                {
                    Version ver = Assembly.GetExecutingAssembly().GetName().Version;

                    Console.WriteLine(String.Format(Resources.Vmc_InfoDisplay_1_Fmt,
                                                    info.Description, info.Support, vc.CurrentUri, info.Version, ver));

                    if (false == info.User.IsNullOrEmpty())
                    {
                        Console.WriteLine(String.Format(Resources.Vmc_InfoDisplay_2_Fmt, info.User));
                    }

                    if (null != info.Usage && null != info.Limits)
                    {
                        string tmem = pretty_size(info.Limits.Memory * 1024 * 1024);
                        string mem  = pretty_size(info.Usage.Memory * 1024 * 1024);

                        Console.WriteLine(String.Format(Resources.Vmc_InfoDisplay_3_Fmt,
                                                        mem, tmem,
                                                        info.Usage.Services, info.Limits.Services,
                                                        info.Usage.Apps, info.Limits.Apps));
                    }
                }
            }
            else
            {
                // TODO standardize errors
                Console.Error.WriteLine(String.Format("Error: {0}", rslt.Message));
            }

            return(rslt.Success);
        }