Пример #1
0
        public CreateCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
        {
            _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory));

            Options.Add(
                "t=|title=",
                "A title for the API key",
                t => _title = ArgumentString.Normalize(t));

            Options.Add(
                "token=",
                "A pre-allocated API key token; by default, a new token will be generated and written to `STDOUT`",
                t => _token = ArgumentString.Normalize(t));

            _properties = Enable <PropertiesFeature>();

            Options.Add(
                "filter=",
                "A filter to apply to incoming events",
                f => _filter = ArgumentString.Normalize(f));

            Options.Add(
                "minimum-level=",
                "The minimum event level/severity to accept; the default is to accept all events",
                v => _level = ArgumentString.Normalize(v));

            Options.Add(
                "use-server-timestamps",
                "Discard client-supplied timestamps and use server clock values",
                _ => _useServerTimestamps = true);

            _connection = Enable <ConnectionFeature>();
            _output     = Enable(new OutputFormatFeature(config.Output));
        }
Пример #2
0
        public RenderCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }
            _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory));

            Options.Add(
                "i=|id=",
                "The id of a single dashboard to render",
                t => _id = ArgumentString.Normalize(t));
            Options.Add("c=|chart=", "The title of a chart on the dashboard to render",
                        c => _chartTitle = ArgumentString.Normalize(c));
            Options.Add("last=",
                        "A duration over which the chart should be rendered, e.g. `7d`; this will be aligned to an interval boundary; either `--last` or `--start` and `--end` must be specified",
                        v => _lastDuration = ArgumentString.Normalize(v));
            Options.Add("by=",
                        "The time-slice interval for the chart data, as a duration, e.g. `1h`",
                        v => _intervalDuration = ArgumentString.Normalize(v));
            _range      = Enable <DateRangeFeature>();
            _signal     = Enable <SignalExpressionFeature>();
            _timeout    = Enable <TimeoutFeature>();
            _output     = Enable(new OutputFormatFeature(config.Output));
            _connection = Enable <ConnectionFeature>();
        }
Пример #3
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);
            }
        }
Пример #4
0
        public CreateCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
        {
            _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory));

            Options.Add(
                "n=|name=",
                "A unique name for the feed",
                n => _name = ArgumentString.Normalize(n));

            Options.Add(
                "l=|location=",
                "The feed location; this may be a NuGet v2 or v3 feed URL, or a local filesystem path on the Seq server",
                l => _location = ArgumentString.Normalize(l));

            Options.Add(
                "u=|username="******"The username Seq should supply when connecting to the feed, if authentication is required",
                n => _username = ArgumentString.Normalize(n));

            Options.Add(
                "p=|password="******"A feed password, if authentication is required; note that `--password-stdin` is more secure",
                p => _password = ArgumentString.Normalize(p));

            Options.Add(
                "password-stdin",
                "Read the feed password from `STDIN`",
                _ => _passwordStdin = true);

            _connection = Enable <ConnectionFeature>();
            _output     = Enable(new OutputFormatFeature(config.Output));
        }
Пример #5
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);
            }
        }
Пример #6
0
        public RunCommand(SeqCliConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }
            _serverUrl = config.Connection.ServerUrl;

            Options.Add(
                "d=|directory=",
                "The directory containing .NET Standard assemblies; defaults to the current directory",
                d => _dir = ArgumentString.Normalize(d) ?? _dir);

            Options.Add(
                "type=",
                "The [SeqApp] plug-in type name; defaults to scanning assemblies for a single type marked with this attribute",
                t => _type = ArgumentString.Normalize(t));

            Options.Add(
                "p={=}|property={=}",
                "Specify name/value settings for the app, e.g. `-p [email protected] -p Subject=\"Alert!\"`",
                (n, v) =>
            {
                var name      = n.Trim();
                var valueText = v?.Trim();
                _settings.Add(name, valueText ?? "");
            });

            Options.Add(
                "storage=",
                "A directory in which app-specific data can be stored; defaults to the current directory",
                d => _storage = ArgumentString.Normalize(d) ?? _storage);

            Options.Add("s=|server=",
                        "The URL of the Seq server, used only for app configuration (no connection is made to the server); by default the `connection.serverUrl` value will be used",
                        v => _serverUrl = ArgumentString.Normalize(v) ?? _serverUrl);

            Options.Add(
                "server-instance=",
                "The instance name of the Seq server, used only for app configuration; defaults to no instance name",
                v => _seqInstanceName = ArgumentString.Normalize(v));

            Options.Add(
                "t=|title=",
                "The app instance title, used only for app configuration; defaults to a placeholder title.",
                v => _appInstanceTitle = ArgumentString.Normalize(v));

            Options.Add(
                "id=",
                "The app instance id, used only for app configuration; defaults to a placeholder id.",
                v => _appInstanceId = ArgumentString.Normalize(v));

            Options.Add(
                "read-env",
                "Read app configuration and settings from environment variables, as specified in " +
                "https://docs.datalust.co/docs/seq-apps-in-other-languages; ignores all options " +
                "except --directory and --type",
                _ => _readEnv = true);
        }
Пример #7
0
 static void List(SeqCliConfig config)
 {
     foreach (var(key, value) in ReadPairs(config))
     {
         Console.WriteLine($"{key}:");
         Console.WriteLine($"  {value}");
     }
 }
Пример #8
0
 static void List(SeqCliConfig config)
 {
     foreach (var pr in ReadPairs(config))
     {
         Console.WriteLine($"{pr.Key}:");
         Console.WriteLine($"  {pr.Value}");
     }
 }
Пример #9
0
 protected override void Load(ContainerBuilder builder)
 {
     builder.RegisterType <CommandLineHost>();
     builder.RegisterAssemblyTypes(typeof(Program).GetTypeInfo().Assembly)
     .As <Command>()
     .WithMetadataFrom <CommandAttribute>();
     builder.RegisterType <SeqConnectionFactory>();
     builder.Register(c => SeqCliConfig.Read()).SingleInstance();
 }
Пример #10
0
 public ImportCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
 {
     if (config == null)
     {
         throw new ArgumentNullException(nameof(config));
     }
     _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory));
     _fileInputFeature  = Enable(new FileInputFeature("File to import"));
     _connection        = Enable <ConnectionFeature>();
 }
Пример #11
0
        protected override Task <int> Run()
        {
            var config = SeqCliConfig.Read();

            foreach (var profile in config.Profiles.OrderBy(p => p.Key))
            {
                Console.WriteLine($"{profile.Key} ({profile.Value.ServerUrl})");
            }

            return(Task.FromResult(0));
        }
Пример #12
0
        public CreateCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
        {
            _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory));

            Options.Add(
                "t=|title=",
                "A title for the API key",
                t => _title = ArgumentString.Normalize(t));

            Options.Add(
                "token=",
                "A pre-allocated API key token; by default, a new token will be generated and written to `STDOUT`",
                t => _token = ArgumentString.Normalize(t));

            _properties = Enable <PropertiesFeature>();

            Options.Add(
                "filter=",
                "A filter to apply to incoming events",
                f => _filter = ArgumentString.Normalize(f));

            Options.Add(
                "minimum-level=",
                "The minimum event level/severity to accept; the default is to accept all events",
                v => _level = ArgumentString.Normalize(v));

            Options.Add(
                "use-server-timestamps",
                "Discard client-supplied timestamps and use server clock values",
                _ => _useServerTimestamps = true);

            Options.Add(
                "permissions=",
                "A comma-separated list of permissions to delegate to the API key; valid permissions are `Ingest` (default), `Read`, `Write`, `Project` and `System`",
                v => _permissions = ArgumentString.NormalizeList(v));

            Options.Add(
                "connect-username="******"A username to connect with, useful primarily when setting up the first API key",
                v => _connectUsername = ArgumentString.Normalize(v));

            Options.Add(
                "connect-password="******"When `connect-username` is specified, a corresponding password",
                v => _connectPassword = ArgumentString.Normalize(v));

            Options.Add(
                "connect-password-stdin",
                "When `connect-username` is specified, read the corresponding password from `STDIN`",
                _ => _connectPasswordStdin = true);

            _connection = Enable <ConnectionFeature>();
            _output     = Enable(new OutputFormatFeature(config.Output));
        }
Пример #13
0
        public ListCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }
            _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory));

            _output     = Enable(new OutputFormatFeature(config.Output));
            _connection = Enable <ConnectionFeature>();
        }
Пример #14
0
        static void Set(SeqCliConfig config, string key, string value)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            var steps = key.Split('.');

            if (steps.Length != 2)
            {
                throw new ArgumentException("The format of the key is incorrect; run the command without any arguments to view all keys.");
            }

            var first = config.GetType().GetTypeInfo().DeclaredProperties
                        .Where(p => p.CanRead && p.GetMethod.IsPublic && !p.GetMethod.IsStatic)
                        .SingleOrDefault(p => Camelize(p.Name) == steps[0]);

            if (first == null)
            {
                throw new ArgumentException("The key could not be found; run the command without any arguments to view all keys.");
            }

            var v = first.GetValue(config);

            if (v is Dictionary <string, SeqCliConnectionConfig> )
            {
                throw new NotSupportedException("Use `seqcli profile create` to configure connection profiles.");
            }

            var second = v.GetType().GetTypeInfo().DeclaredProperties
                         .Where(p => p.CanRead && p.GetMethod.IsPublic && !p.GetMethod.IsStatic)
                         .SingleOrDefault(p => Camelize(p.Name) == steps[1]);

            if (second == null)
            {
                throw new ArgumentException("The key could not be found; run the command without any arguments to view all keys.");
            }

            if (!second.SetMethod.IsPublic)
            {
                throw new ArgumentException("The value is not writeable.");
            }

            var targetValue = Convert.ChangeType(value, second.PropertyType);

            second.SetValue(v, targetValue);
        }
Пример #15
0
        public TailCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
        {
            _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory));

            Options.Add(
                "f=|filter=",
                "An optional server-side filter to apply to the stream, for example `@Level = 'Error'`",
                v => _filter = v);

            _output     = Enable(new OutputFormatFeature(config.Output));
            _signal     = Enable <SignalExpressionFeature>();
            _connection = Enable <ConnectionFeature>();
        }
Пример #16
0
        public ListCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }
            _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory));

            _entityIdentity = Enable(new EntityIdentityFeature("workspace", "list"));
            _entityOwner    = Enable(new EntityOwnerFeature("workspace", "list", _entityIdentity));
            _output         = Enable(new OutputFormatFeature(config.Output));
            _connection     = Enable <ConnectionFeature>();
        }
Пример #17
0
 public QueryCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
 {
     if (config == null)
     {
         throw new ArgumentNullException(nameof(config));
     }
     _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory));
     Options.Add("q=|query=", "The query to execute", v => _query = v);
     _range  = Enable <DateRangeFeature>();
     _signal = Enable <SignalExpressionFeature>();
     Options.Add("timeout=", "The query execution timeout in milliseconds", v => _timeoutMS = int.Parse(v?.Trim() ?? "0"));
     _output     = Enable(new OutputFormatFeature(config.Output));
     _connection = Enable <ConnectionFeature>();
 }
Пример #18
0
        public ListCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }
            _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory));

            Options.Add(
                "i=|id=",
                "The id of a single retention policy to list",
                id => _id = id);

            _output     = Enable(new OutputFormatFeature(config.Output));
            _connection = Enable <ConnectionFeature>();
        }
Пример #19
0
        public CreateCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
        {
            _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory));

            Options.Add(
                "n=|name=",
                "A unique username for the user",
                u => _username = ArgumentString.Normalize(u));

            Options.Add(
                "d=|display-name=",
                "A long-form name to aid in identifying the user",
                d => _displayName = ArgumentString.Normalize(d));

            Options.Add(
                "f=|filter=",
                "A view filter that limits the events visible to the user",
                f => _filter = ArgumentString.Normalize(f));

            Options.Add(
                "r=|role=",
                "The title of a role that grants the user permissions on the server; if not specified, the default new user role will be assigned",
                r => _roleTitle = ArgumentString.Normalize(r));

            Options.Add(
                "e=|email=",
                "The user's email address (enables a Gravatar image for the user)",
                e => _emailAddress = ArgumentString.Normalize(e));

            Options.Add(
                "p=|password="******"An initial password for the user, if username/password authentication is in use; note that `--password-stdin` is more secure",
                p => _password = ArgumentString.Normalize(p));

            Options.Add(
                "password-stdin",
                "Read the initial password for the user from `STDIN`, if username/password authentication is in use",
                _ => _passwordStdin = true);

            Options.Add(
                "no-password-change",
                "Don't force the user to change their password at next login",
                _ => _noPasswordChange = true);

            _connection = Enable <ConnectionFeature>();
            _output     = Enable(new OutputFormatFeature(config.Output));
        }
Пример #20
0
        bool _deleteAllEvents; // Currently the only supported option

        public CreateCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
        {
            _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory));

            Options.Add(
                "after=",
                "A duration after which the policy will delete events, e.g. `7d`",
                v => _afterDuration = ArgumentString.Normalize(v));

            Options.Add(
                "delete-all-events",
                "The policy should delete all events (currently the only supported option)",
                _ => _deleteAllEvents = true);

            _connection = Enable <ConnectionFeature>();
            _output     = Enable(new OutputFormatFeature(config.Output));
        }
Пример #21
0
        public ImportCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }
            _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory));

            Options.Add(
                "merge",
                "Update signals that have ids matching those in the imported data; the default is to always create new signals",
                _ => _merge = true);

            _fileInputFeature = Enable(new FileInputFeature("File to import"));
            _entityOwner      = Enable(new EntityOwnerFeature("signal", "import"));
            _connection       = Enable <ConnectionFeature>();
        }
Пример #22
0
        public SearchCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
        {
            _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory));

            Options.Add(
                "f=|filter=",
                "A filter to apply to the search, for example `Host = 'xmpweb-01.example.com'`",
                v => _filter = v);
            Options.Add(
                "c=|count=",
                $"The maximum number of events to retrieve; the default is {_count}",
                v => _count = int.Parse(v, CultureInfo.InvariantCulture));

            _range      = Enable <DateRangeFeature>();
            _output     = Enable(new OutputFormatFeature(config.Output));
            _signal     = Enable <SignalExpressionFeature>();
            _connection = Enable <ConnectionFeature>();
        }
Пример #23
0
        static void Set(SeqCliConfig config, string key, string value)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            var steps = key.Split('.');

            if (steps.Length != 2)
            {
                throw new ArgumentException("The format of the key is incorrect; run the command without any arguments to view all keys.");
            }

            var first = config.GetType().GetTypeInfo().DeclaredProperties
                        .Where(p => p.GetMethod.IsPublic && !p.GetMethod.IsStatic)
                        .SingleOrDefault(p => Camelize(p.Name) == steps[0]);

            if (first == null)
            {
                throw new ArgumentException("The key could not be found; run the command without any arguments to view all keys.");
            }

            var v = first.GetValue(config);

            var second = v.GetType().GetTypeInfo().DeclaredProperties
                         .Where(p => p.GetMethod.IsPublic && p.SetMethod.IsPublic && !p.GetMethod.IsStatic)
                         .SingleOrDefault(p => Camelize(p.Name) == steps[1]);

            if (second == null)
            {
                throw new ArgumentException("The key could not be found; run the command without any arguments to view all keys.");
            }

            var targetValue = Convert.ChangeType(value, second.PropertyType);

            second.SetValue(v, targetValue);
        }
Пример #24
0
        static void Print(SeqCliConfig config, string key)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            var pr = ReadPairs(config).SingleOrDefault(p => p.Key == key);

            if (pr.Key == null)
            {
                throw new ArgumentException($"Option {key} not found.");
            }

            Console.WriteLine(pr.Value);
        }
Пример #25
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));
            }
        }
Пример #26
0
        public DefineCommand(SeqCliConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            Options.Add(
                "d=|directory=",
                "The directory containing .NET Standard assemblies; defaults to the current directory",
                d => _dir = ArgumentString.Normalize(d) ?? _dir);

            Options.Add(
                "type=",
                "The [SeqApp] plug-in type name; defaults to scanning assemblies for a single type marked with this attribute",
                t => _type = ArgumentString.Normalize(t));

            Options.Add(
                "indented",
                "Format the definition over multiple lines with indentation",
                _ => _indented = true);
        }
Пример #27
0
        public CreateCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
        {
            _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory));

            Options.Add(
                "t=|title=",
                "A title for the workspace",
                t => _title = ArgumentString.Normalize(t));

            Options.Add(
                "description=",
                "A description for the workspace",
                d => _description = ArgumentString.Normalize(d));

            Options.Add(
                "dashboard=",
                "The id of a dashboard to include in the workspace",
                d => _dashboards.Add(ArgumentString.Normalize(d)));

            Options.Add(
                "query=",
                "The id of a saved query to include in the workspace",
                s => _queries.Add(ArgumentString.Normalize(s)));

            Options.Add(
                "signal=",
                "The id of a signal to include in the workspace",
                s => _signals.Add(ArgumentString.Normalize(s)));

            Options.Add(
                "protected",
                "Specify that the workspace is editable only by administrators",
                _ => _isProtected = true);

            _connection = Enable <ConnectionFeature>();
            _output     = Enable(new OutputFormatFeature(config.Output));
        }
Пример #28
0
        public CreateCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
        {
            _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory));

            Options.Add(
                "t=|title=",
                "A title for the signal",
                t => _title = ArgumentString.Normalize(t));

            Options.Add(
                "description=",
                "A description for the signal",
                d => _description = ArgumentString.Normalize(d));

            Options.Add(
                "f=|filter=",
                "Filter to associate with the signal",
                f => _filter = ArgumentString.Normalize(f));

            Options.Add(
                "group=",
                "An explicit group name to associate with the signal; the default is to infer the group from the filter",
                g => _group = ArgumentString.Normalize(g));

            Options.Add(
                "no-group",
                "Specify that no group should be inferred; the default is to infer the group from the filter",
                _ => _noGrouping = true);

            Options.Add(
                "protected",
                "Specify that the signal is editable only by administrators",
                _ => _isProtected = true);

            _connection = Enable <ConnectionFeature>();
            _output     = Enable(new OutputFormatFeature(config.Output));
        }
Пример #29
0
        public RunCommand(SeqCliConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }
            _serverUrl = config.Connection.ServerUrl;

            Options.Add(
                "d=|directory=",
                "The directory containing .NET Standard assemblies; defaults to the current directory",
                d => _dir = ArgumentString.Normalize(d) ?? _dir);

            Options.Add(
                "t|type=",
                "The [SeqApp] plug-in type name; defaults to scanning assemblies for a single type marked with this attribute",
                t => _type = ArgumentString.Normalize(t));

            Options.Add(
                "p={=}|property={=}",
                "Specify name/value settings for the app, e.g. `-p [email protected] -p Subject=\"Alert!\"`",
                (n, v) =>
            {
                var name      = n.Trim();
                var valueText = v?.Trim();
                _settings.Add(name, valueText ?? "");
            });

            Options.Add("s=|server=",
                        "The URL of the Seq server, used only for app configuration (no connection is made to the server); by default the `connection.serverUrl` value will be used",
                        v => _serverUrl = ArgumentString.Normalize(v) ?? _serverUrl);

            Options.Add(
                "storage=",
                "A directory in which app-specific data can be stored; defaults to the current directory",
                d => _storage = ArgumentString.Normalize(d) ?? _storage);
        }
Пример #30
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));
            }
        }