Ejemplo n.º 1
0
        int RunSync()
        {
            if (_name == null)
            {
                Log.Error("A profile name is required");
                return(1);
            }

            if (_url == null)
            {
                Log.Error("A server URL is required");
                return(1);
            }

            try
            {
                var config = SeqCliConfig.Read();
                config.Profiles[_name] = new SeqCliConnectionConfig {
                    ServerUrl = _url, ApiKey = _apiKey
                };
                SeqCliConfig.Write(config);
                return(0);
            }
            catch (Exception ex)
            {
                Log.Error("Could not create profile: {ErrorMessage}", Presentation.FormattedMessage(ex));
                return(1);
            }
        }
Ejemplo n.º 2
0
        int RunSync()
        {
            if (_name == null)
            {
                Log.Error("A profile name is required");
                return(1);
            }

            try
            {
                var config = SeqCliConfig.Read();
                if (!config.Profiles.Remove(_name))
                {
                    Log.Error("No profile with name {ProfileName} was found", _name);
                    return(1);
                }

                SeqCliConfig.Write(config);

                return(0);
            }
            catch (Exception ex)
            {
                Log.Error("Could not create profile: {ErrorMessage}", Presentation.FormattedMessage(ex));
                return(1);
            }
        }
Ejemplo n.º 3
0
        protected override Task <int> Run()
        {
            var verb = "read";

            try
            {
                var config = SeqCliConfig.Read();

                if (_key != null)
                {
                    if (_clear)
                    {
                        verb = "clear";
                        Clear(config, _key);
                        SeqCliConfig.Write(config);
                    }
                    else if (_value != null)
                    {
                        verb = "update";
                        Set(config, _key, _value);
                        SeqCliConfig.Write(config);
                    }
                    else
                    {
                        Print(config, _key);
                    }
                }
                else
                {
                    List(config);
                }

                return(Task.FromResult(0));
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Could not {Verb} config: {ErrorMessage}", verb, Presentation.FormattedMessage(ex));
                return(Task.FromResult(1));
            }
        }
Ejemplo n.º 4
0
        protected override Task <int> Run()
        {
            try
            {
                var config = SeqCliConfig.Read();

                if (_key != null)
                {
                    if (_clear)
                    {
                        Clear(config, _key);
                        SeqCliConfig.Write(config);
                    }
                    else if (_value != null)
                    {
                        Set(config, _key, _value);
                        SeqCliConfig.Write(config);
                    }
                    else
                    {
                        Print(config, _key);
                    }
                }
                else
                {
                    List(config);
                }

                return(Task.FromResult(0));
            }
            catch (Exception ex)
            {
                Log.Fatal(ex, "Could not update config: {ErrorMessage}", ex.Message);
                return(Task.FromResult(1));
            }
        }