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); } }
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); } }
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(); }
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)); }
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)); } }
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)); } }