diff --git a/src/SeqCli/Apps/Definitions/AppDefinition.cs b/src/SeqCli/Apps/Definitions/AppDefinition.cs index 49f95536..5c9e1773 100644 --- a/src/SeqCli/Apps/Definitions/AppDefinition.cs +++ b/src/SeqCli/Apps/Definitions/AppDefinition.cs @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#nullable enable - using System.Collections.Generic; using Newtonsoft.Json; diff --git a/src/SeqCli/Apps/Definitions/AppMetadataReader.cs b/src/SeqCli/Apps/Definitions/AppMetadataReader.cs index a34a6eb3..8abd7be0 100644 --- a/src/SeqCli/Apps/Definitions/AppMetadataReader.cs +++ b/src/SeqCli/Apps/Definitions/AppMetadataReader.cs @@ -19,8 +19,6 @@ using System.Reflection; using Seq.Apps; -#nullable enable - namespace SeqCli.Apps.Definitions; static class AppMetadataReader diff --git a/src/SeqCli/Apps/Definitions/AppSettingDefinition.cs b/src/SeqCli/Apps/Definitions/AppSettingDefinition.cs index dec00cb6..00ebeb8e 100644 --- a/src/SeqCli/Apps/Definitions/AppSettingDefinition.cs +++ b/src/SeqCli/Apps/Definitions/AppSettingDefinition.cs @@ -14,8 +14,6 @@ using Newtonsoft.Json; -#nullable enable - namespace SeqCli.Apps.Definitions; // ReSharper disable all diff --git a/src/SeqCli/Cli/CommandLineHost.cs b/src/SeqCli/Cli/CommandLineHost.cs index e2ac7e7d..e5c686fc 100644 --- a/src/SeqCli/Cli/CommandLineHost.cs +++ b/src/SeqCli/Cli/CommandLineHost.cs @@ -21,8 +21,6 @@ using Serilog.Core; using Serilog.Events; -#nullable enable - namespace SeqCli.Cli; class CommandLineHost diff --git a/src/SeqCli/Cli/Commands/App/InstallCommand.cs b/src/SeqCli/Cli/Commands/App/InstallCommand.cs index 6f65da1d..94d98482 100644 --- a/src/SeqCli/Cli/Commands/App/InstallCommand.cs +++ b/src/SeqCli/Cli/Commands/App/InstallCommand.cs @@ -22,8 +22,6 @@ using SeqCli.Util; using Serilog; -#nullable enable - namespace SeqCli.Cli.Commands.App; [Command("app", "install", "Install an app package", diff --git a/src/SeqCli/Cli/Commands/App/UpdateCommand.cs b/src/SeqCli/Cli/Commands/App/UpdateCommand.cs index 671e2594..bf7fb40f 100644 --- a/src/SeqCli/Cli/Commands/App/UpdateCommand.cs +++ b/src/SeqCli/Cli/Commands/App/UpdateCommand.cs @@ -21,8 +21,6 @@ using SeqCli.Util; using Serilog; -#nullable enable - namespace SeqCli.Cli.Commands.App; [Command("app", "update", "Update an installed app package", diff --git a/src/SeqCli/Cli/Commands/Bench/BenchCase.cs b/src/SeqCli/Cli/Commands/Bench/BenchCase.cs index 97f2e240..8305911f 100644 --- a/src/SeqCli/Cli/Commands/Bench/BenchCase.cs +++ b/src/SeqCli/Cli/Commands/Bench/BenchCase.cs @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#nullable enable - namespace SeqCli.Cli.Commands.Bench; // ReSharper disable ClassNeverInstantiated.Global AutoPropertyCanBeMadeGetOnly.Global UnusedAutoPropertyAccessor.Global diff --git a/src/SeqCli/Cli/Commands/Bench/BenchCaseTimings.cs b/src/SeqCli/Cli/Commands/Bench/BenchCaseTimings.cs index 1e49a257..e9b35407 100644 --- a/src/SeqCli/Cli/Commands/Bench/BenchCaseTimings.cs +++ b/src/SeqCli/Cli/Commands/Bench/BenchCaseTimings.cs @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#nullable enable using System; using System.Collections.Generic; using System.Linq; diff --git a/src/SeqCli/Cli/Commands/Bench/BenchCasesCollection.cs b/src/SeqCli/Cli/Commands/Bench/BenchCasesCollection.cs index c250f4e9..93f28e04 100644 --- a/src/SeqCli/Cli/Commands/Bench/BenchCasesCollection.cs +++ b/src/SeqCli/Cli/Commands/Bench/BenchCasesCollection.cs @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#nullable enable using System.Collections.Generic; namespace SeqCli.Cli.Commands.Bench; diff --git a/src/SeqCli/Cli/Commands/Bench/BenchCommand.cs b/src/SeqCli/Cli/Commands/Bench/BenchCommand.cs index f6cc8011..1bad7970 100644 --- a/src/SeqCli/Cli/Commands/Bench/BenchCommand.cs +++ b/src/SeqCli/Cli/Commands/Bench/BenchCommand.cs @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#nullable enable - using System; using System.IO; using System.Linq; diff --git a/src/SeqCli/Cli/Commands/License/ApplyCommand.cs b/src/SeqCli/Cli/Commands/License/ApplyCommand.cs index c4297559..7f2970b7 100644 --- a/src/SeqCli/Cli/Commands/License/ApplyCommand.cs +++ b/src/SeqCli/Cli/Commands/License/ApplyCommand.cs @@ -9,8 +9,6 @@ // ReSharper disable once UnusedType.Global -#nullable enable - namespace SeqCli.Cli.Commands.License; [Command("license", "apply", "Apply a license to the Seq server", diff --git a/src/SeqCli/Cli/Commands/Node/DemoteCommand.cs b/src/SeqCli/Cli/Commands/Node/DemoteCommand.cs index fccbf076..382d06a5 100644 --- a/src/SeqCli/Cli/Commands/Node/DemoteCommand.cs +++ b/src/SeqCli/Cli/Commands/Node/DemoteCommand.cs @@ -1,4 +1,18 @@ -using System; +// Copyright Datalust Pty Ltd and Contributors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; using System.Linq; using System.Threading.Tasks; using Seq.Api.Model.Cluster; @@ -6,8 +20,6 @@ using SeqCli.Connection; using Serilog; -#nullable enable - namespace SeqCli.Cli.Commands.Node; [Command("node", "demote", "Begin demotion of the current leader node", diff --git a/src/SeqCli/Cli/Commands/Node/HealthCommand.cs b/src/SeqCli/Cli/Commands/Node/HealthCommand.cs index c94eeea5..24dad8f1 100644 --- a/src/SeqCli/Cli/Commands/Node/HealthCommand.cs +++ b/src/SeqCli/Cli/Commands/Node/HealthCommand.cs @@ -1,4 +1,18 @@ -using System; +// Copyright Datalust Pty Ltd and Contributors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; using System.Globalization; using System.Linq; using System.Threading.Tasks; @@ -7,8 +21,6 @@ using SeqCli.Util; using Serilog; -#nullable enable - namespace SeqCli.Cli.Commands.Node; [Command("node", "health", diff --git a/src/SeqCli/Cli/Commands/Node/ListCommand.cs b/src/SeqCli/Cli/Commands/Node/ListCommand.cs index 0e11e039..bf030933 100644 --- a/src/SeqCli/Cli/Commands/Node/ListCommand.cs +++ b/src/SeqCli/Cli/Commands/Node/ListCommand.cs @@ -19,8 +19,6 @@ using SeqCli.Config; using SeqCli.Connection; -#nullable enable - namespace SeqCli.Cli.Commands.Node; [Command("node", "list", "List nodes in the Seq cluster", diff --git a/src/SeqCli/Cli/Commands/SearchCommand.cs b/src/SeqCli/Cli/Commands/SearchCommand.cs index 2f1c9a08..51b83ff0 100644 --- a/src/SeqCli/Cli/Commands/SearchCommand.cs +++ b/src/SeqCli/Cli/Commands/SearchCommand.cs @@ -28,8 +28,6 @@ using Serilog.Parsing; // ReSharper disable UnusedType.Global -#nullable enable - namespace SeqCli.Cli.Commands; [Command("search", "Retrieve log events that match a given filter", diff --git a/src/SeqCli/Cli/Commands/Settings/ClearCommand.cs b/src/SeqCli/Cli/Commands/Settings/ClearCommand.cs new file mode 100644 index 00000000..e4025de8 --- /dev/null +++ b/src/SeqCli/Cli/Commands/Settings/ClearCommand.cs @@ -0,0 +1,48 @@ +// Copyright Datalust Pty Ltd and Contributors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Threading.Tasks; +using SeqCli.Cli.Features; +using SeqCli.Connection; + +namespace SeqCli.Cli.Commands.Settings; + +[Command("setting", "clear", "Clear a runtime-configurable server setting")] +class ClearCommand: Command +{ + readonly SeqConnectionFactory _connectionFactory; + + readonly ConnectionFeature _connection; + readonly SettingNameFeature _name; + + public ClearCommand(SeqConnectionFactory connectionFactory) + { + _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory)); + + _name = Enable(); + _connection = Enable(); + } + + protected override async Task Run() + { + var connection = _connectionFactory.Connect(_connection); + + var setting = await connection.Settings.FindNamedAsync(_name.Name); + setting.Value = null; + await connection.Settings.UpdateAsync(setting); + + return 0; + } +} \ No newline at end of file diff --git a/src/SeqCli/Cli/Commands/Settings/NamesCommand.cs b/src/SeqCli/Cli/Commands/Settings/NamesCommand.cs new file mode 100644 index 00000000..40f060d5 --- /dev/null +++ b/src/SeqCli/Cli/Commands/Settings/NamesCommand.cs @@ -0,0 +1,34 @@ +// Copyright Datalust Pty Ltd and Contributors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Linq; +using System.Threading.Tasks; +using Seq.Api.Model.Settings; + +namespace SeqCli.Cli.Commands.Settings; + +[Command("setting", "names", "Print the names of all supported settings")] +class NamesCommand: Command +{ + protected override Task Run(string[] unrecognized) + { + foreach (var name in Enum.GetNames(typeof(SettingName)).Order()) + { + Console.WriteLine(name); + } + + return Task.FromResult(0); + } +} \ No newline at end of file diff --git a/src/SeqCli/Cli/Commands/Settings/SetCommand.cs b/src/SeqCli/Cli/Commands/Settings/SetCommand.cs new file mode 100644 index 00000000..67ad8844 --- /dev/null +++ b/src/SeqCli/Cli/Commands/Settings/SetCommand.cs @@ -0,0 +1,80 @@ +// Copyright Datalust Pty Ltd and Contributors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Threading.Tasks; +using SeqCli.Cli.Features; +using SeqCli.Connection; +using Serilog; + +namespace SeqCli.Cli.Commands.Settings; + +[Command("setting", "set", "Change a runtime-configurable server setting")] +class SetCommand: Command +{ + readonly SeqConnectionFactory _connectionFactory; + + readonly ConnectionFeature _connection; + readonly SettingNameFeature _name; + + string? _value; + bool _valueSpecified, _readValueFromStdin; + + public SetCommand(SeqConnectionFactory connectionFactory) + { + _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory)); + + _name = Enable(); + + Options.Add("v|value=", + "The setting value, comma-separated if multiple values are accepted", + v => + { + // Not normalized; some settings might include leading/trailing whitespace. + _valueSpecified = true; + _value = v; + }); + + Options.Add("value-stdin", + "Read the value from `STDIN`", + _ => _readValueFromStdin = true); + + _connection = Enable(); + } + + protected override async Task Run() + { + if (!_valueSpecified && !_readValueFromStdin) + { + Log.Error("A value must be supplied with either `--value=VALUE` or `--value-stdin`."); + return 1; + } + + var connection = _connectionFactory.Connect(_connection); + + var setting = await connection.Settings.FindNamedAsync(_name.Name); + setting.Value = ReadValue(); + await connection.Settings.UpdateAsync(setting); + + return 0; + } + + string? ReadValue() + { + if (_readValueFromStdin) + return Console.In.ReadToEnd().TrimEnd('\r', '\n'); + + return _value; + } +} \ No newline at end of file diff --git a/src/SeqCli/Cli/Commands/Settings/ShowCommand.cs b/src/SeqCli/Cli/Commands/Settings/ShowCommand.cs new file mode 100644 index 00000000..e351b41d --- /dev/null +++ b/src/SeqCli/Cli/Commands/Settings/ShowCommand.cs @@ -0,0 +1,52 @@ +// Copyright Datalust Pty Ltd and Contributors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Globalization; +using System.Threading.Tasks; +using SeqCli.Cli.Features; +using SeqCli.Connection; + +namespace SeqCli.Cli.Commands.Settings; + +[Command("setting", "show", "Print the current value of a runtime-configurable server setting")] +class ShowCommand: Command +{ + readonly SeqConnectionFactory _connectionFactory; + + readonly ConnectionFeature _connection; + readonly SettingNameFeature _name; + + public ShowCommand(SeqConnectionFactory connectionFactory) + { + _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory)); + + _name = Enable(); + _connection = Enable(); + } + + protected override async Task Run() + { + var connection = _connectionFactory.Connect(_connection); + + var setting = await connection.Settings.FindNamedAsync(_name.Name); + + if (setting.Value != null) + { + Console.Write(setting.Value is IFormattable f ? f.ToString(null, CultureInfo.InvariantCulture) : setting.Value.ToString()); + } + + return 0; + } +} diff --git a/src/SeqCli/Cli/Commands/Template/ExportCommand.cs b/src/SeqCli/Cli/Commands/Template/ExportCommand.cs index 1c254881..d9b654ec 100644 --- a/src/SeqCli/Cli/Commands/Template/ExportCommand.cs +++ b/src/SeqCli/Cli/Commands/Template/ExportCommand.cs @@ -10,8 +10,6 @@ // ReSharper disable once UnusedType.Global -#nullable enable - namespace SeqCli.Cli.Commands.Template; [Command("template", "export", "Export entities into template files", diff --git a/src/SeqCli/Cli/Commands/Template/ImportCommand.cs b/src/SeqCli/Cli/Commands/Template/ImportCommand.cs index 479f5019..0d902ebf 100644 --- a/src/SeqCli/Cli/Commands/Template/ImportCommand.cs +++ b/src/SeqCli/Cli/Commands/Template/ImportCommand.cs @@ -13,8 +13,6 @@ // ReSharper disable once UnusedType.Global -#nullable enable - namespace SeqCli.Cli.Commands.Template; // Uses an import directory rather than individual files, so that name resolution diff --git a/src/SeqCli/Cli/Commands/VersionCommand.cs b/src/SeqCli/Cli/Commands/VersionCommand.cs index 7640f419..411d7523 100644 --- a/src/SeqCli/Cli/Commands/VersionCommand.cs +++ b/src/SeqCli/Cli/Commands/VersionCommand.cs @@ -16,8 +16,6 @@ using System.Reflection; using System.Threading.Tasks; -#nullable enable - namespace SeqCli.Cli.Commands; [Command("version", "Print the current executable version")] diff --git a/src/SeqCli/Cli/Features/ConnectionFeature.cs b/src/SeqCli/Cli/Features/ConnectionFeature.cs index aff5eef1..e832e8c9 100644 --- a/src/SeqCli/Cli/Features/ConnectionFeature.cs +++ b/src/SeqCli/Cli/Features/ConnectionFeature.cs @@ -14,8 +14,6 @@ using SeqCli.Util; -#nullable enable - namespace SeqCli.Cli.Features; class ConnectionFeature : CommandFeature diff --git a/src/SeqCli/Cli/Features/PropertiesFeature.cs b/src/SeqCli/Cli/Features/PropertiesFeature.cs index abc73aa7..408d3dbf 100644 --- a/src/SeqCli/Cli/Features/PropertiesFeature.cs +++ b/src/SeqCli/Cli/Features/PropertiesFeature.cs @@ -14,8 +14,6 @@ using System.Collections.Generic; -#nullable enable - namespace SeqCli.Cli.Features; class PropertiesFeature : CommandFeature diff --git a/src/SeqCli/Cli/Features/SettingNameFeature.cs b/src/SeqCli/Cli/Features/SettingNameFeature.cs new file mode 100644 index 00000000..c089c2a6 --- /dev/null +++ b/src/SeqCli/Cli/Features/SettingNameFeature.cs @@ -0,0 +1,46 @@ +// Copyright 2018 Datalust Pty Ltd +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Collections.Generic; +using Seq.Api.Model.Settings; +using SeqCli.Util; +using Serilog; + +namespace SeqCli.Cli.Features; + +class SettingNameFeature: CommandFeature +{ + string? _name; + + public SettingName Name => Enum.Parse(_name!, ignoreCase: true); + + public override void Enable(OptionSet options) + { + options.Add("n|name=", "The setting name, for example `OpenIdConnectClientSecret`", k => _name = ArgumentString.Normalize(k)); + } + + public override IEnumerable GetUsageErrors() + { + if (string.IsNullOrEmpty(_name)) + { + yield return "A setting must be specified with `--name=NAME`."; + } + + if (!Enum.TryParse(_name, ignoreCase: true, out SettingName _)) + { + yield return $"The setting name {_name} was not recognized; run the `seqcli setting names` command to see supported settings."; + } + } +} \ No newline at end of file diff --git a/src/SeqCli/Connection/SeqConnectionFactory.cs b/src/SeqCli/Connection/SeqConnectionFactory.cs index d228a6ec..08ef3cfb 100644 --- a/src/SeqCli/Connection/SeqConnectionFactory.cs +++ b/src/SeqCli/Connection/SeqConnectionFactory.cs @@ -17,8 +17,6 @@ using SeqCli.Cli.Features; using SeqCli.Config; -#nullable enable - namespace SeqCli.Connection; class SeqConnectionFactory diff --git a/src/SeqCli/Templates/Export/EntityName.cs b/src/SeqCli/Templates/Export/EntityName.cs index 46eecc4b..34512914 100644 --- a/src/SeqCli/Templates/Export/EntityName.cs +++ b/src/SeqCli/Templates/Export/EntityName.cs @@ -1,8 +1,6 @@ using System; using Seq.Api.Model; -#nullable enable - namespace SeqCli.Templates.Export; static class EntityName diff --git a/src/SeqCli/Templates/Export/TemplateSetExporter.cs b/src/SeqCli/Templates/Export/TemplateSetExporter.cs index 488b00d8..051a3cda 100644 --- a/src/SeqCli/Templates/Export/TemplateSetExporter.cs +++ b/src/SeqCli/Templates/Export/TemplateSetExporter.cs @@ -14,8 +14,6 @@ using Seq.Api.Model.Workspaces; using Serilog; -#nullable enable - namespace SeqCli.Templates.Export; class TemplateSetExporter diff --git a/src/SeqCli/Templates/Export/TemplateValueMap.cs b/src/SeqCli/Templates/Export/TemplateValueMap.cs index 4f0e92d4..19ddf2e8 100644 --- a/src/SeqCli/Templates/Export/TemplateValueMap.cs +++ b/src/SeqCli/Templates/Export/TemplateValueMap.cs @@ -4,8 +4,6 @@ using System.Reflection; using Newtonsoft.Json; -#nullable enable - namespace SeqCli.Templates.Export; class TemplateValueMap diff --git a/src/SeqCli/Templates/Export/TemplateWriter.cs b/src/SeqCli/Templates/Export/TemplateWriter.cs index d05fd15e..cc8650a0 100644 --- a/src/SeqCli/Templates/Export/TemplateWriter.cs +++ b/src/SeqCli/Templates/Export/TemplateWriter.cs @@ -9,8 +9,6 @@ using Newtonsoft.Json; using Seq.Api.Model; -#nullable enable - namespace SeqCli.Templates.Export; static class TemplateWriter diff --git a/src/SeqCli/Templates/Import/EntityTemplateFileLoader.cs b/src/SeqCli/Templates/Import/EntityTemplateFileLoader.cs index 5c3f2275..949daf07 100644 --- a/src/SeqCli/Templates/Import/EntityTemplateFileLoader.cs +++ b/src/SeqCli/Templates/Import/EntityTemplateFileLoader.cs @@ -18,8 +18,6 @@ using SeqCli.Templates.Export; using SeqCli.Templates.Parser; -#nullable enable - namespace SeqCli.Templates.Import; static class EntityTemplateLoader diff --git a/src/SeqCli/Templates/Import/EntityTemplateFunctions.cs b/src/SeqCli/Templates/Import/EntityTemplateFunctions.cs index b45661e7..fd3afac0 100644 --- a/src/SeqCli/Templates/Import/EntityTemplateFunctions.cs +++ b/src/SeqCli/Templates/Import/EntityTemplateFunctions.cs @@ -3,8 +3,6 @@ using SeqCli.Templates.Ast; using SeqCli.Templates.Evaluator; -#nullable enable - namespace SeqCli.Templates.Import; class EntityTemplateFunctions diff --git a/src/SeqCli/Templates/Import/GenericEntity.cs b/src/SeqCli/Templates/Import/GenericEntity.cs index a3641de7..d86a28f0 100644 --- a/src/SeqCli/Templates/Import/GenericEntity.cs +++ b/src/SeqCli/Templates/Import/GenericEntity.cs @@ -14,8 +14,6 @@ using Seq.Api.Model; -#nullable enable - namespace SeqCli.Templates.Import; // ReSharper disable once ClassNeverInstantiated.Global diff --git a/src/SeqCli/Templates/Import/TemplateImportState.cs b/src/SeqCli/Templates/Import/TemplateImportState.cs index 18505a35..5a0eb86f 100644 --- a/src/SeqCli/Templates/Import/TemplateImportState.cs +++ b/src/SeqCli/Templates/Import/TemplateImportState.cs @@ -5,8 +5,6 @@ using System.Text.Json; using System.Threading.Tasks; -#nullable enable - namespace SeqCli.Templates.Import; class TemplateImportState diff --git a/src/SeqCli/Templates/Import/TemplateSetImporter.cs b/src/SeqCli/Templates/Import/TemplateSetImporter.cs index 95105390..8ac069c8 100644 --- a/src/SeqCli/Templates/Import/TemplateSetImporter.cs +++ b/src/SeqCli/Templates/Import/TemplateSetImporter.cs @@ -27,8 +27,6 @@ // ReSharper disable SuggestBaseTypeForParameter, CommentTypo -#nullable enable - namespace SeqCli.Templates.Import; static class TemplateSetImporter diff --git a/src/SeqCli/Util/ArgumentString.cs b/src/SeqCli/Util/ArgumentString.cs index fbac7317..90c539e8 100644 --- a/src/SeqCli/Util/ArgumentString.cs +++ b/src/SeqCli/Util/ArgumentString.cs @@ -14,8 +14,6 @@ using System.Linq; -#nullable enable - namespace SeqCli.Util; static class ArgumentString diff --git a/src/SeqCli/Util/Presentation.cs b/src/SeqCli/Util/Presentation.cs index 060eae18..b6e498d2 100644 --- a/src/SeqCli/Util/Presentation.cs +++ b/src/SeqCli/Util/Presentation.cs @@ -16,8 +16,6 @@ using System.Reflection; using System.Text; -#nullable enable - namespace SeqCli.Util; static class Presentation diff --git a/test/SeqCli.EndToEnd/Settings/SettingBasicsTestCase.cs b/test/SeqCli.EndToEnd/Settings/SettingBasicsTestCase.cs new file mode 100644 index 00000000..f387a400 --- /dev/null +++ b/test/SeqCli.EndToEnd/Settings/SettingBasicsTestCase.cs @@ -0,0 +1,41 @@ +using System; +using System.Threading.Tasks; +using Seq.Api; +using SeqCli.EndToEnd.Support; +using Serilog; +using Xunit; + +namespace SeqCli.EndToEnd.Settings; + +public class SettingBasicsTestCase : ICliTestCase +{ + public Task ExecuteAsync( + SeqConnection connection, + ILogger logger, + CliCommandRunner runner) + { + var exit = runner.Exec("setting names"); + Assert.Equal(0, exit); + Assert.Contains("InstanceTitle", runner.LastRunProcess!.Output); + + exit = runner.Exec("setting show", "-n instancetitle"); + Assert.Equal(0, exit); + Assert.Empty(runner.LastRunProcess.Output); + + exit = runner.Exec("setting set", "-n instancetitle -v \"Hello, world!\""); + Assert.Equal(0, exit); + + exit = runner.Exec("setting show", "-n instancetitle"); + Assert.Equal(0, exit); + Assert.Equal("Hello, world!", runner.LastRunProcess.Output.Trim()); + + exit = runner.Exec("setting clear", "-n instancetitle"); + Assert.Equal(0, exit); + + exit = runner.Exec("setting show", "-n instancetitle"); + Assert.Equal(0, exit); + Assert.Empty(runner.LastRunProcess.Output); + + return Task.CompletedTask; + } +}