static async Task Main(string[] args) { var timer = Stopwatch.StartNew(); try { logger = InitialiseLogging(); try { AvailableDays = LoadDays().ToList(); await BuildCommandLine() .UseDefaults() .Build() .InvokeAsync(args); } catch (Exception ex) { logger.Error(ex, "Error running AoC with args: {@Args}", args); AnsiConsole.WriteException(ex); } finally { Serilog.Log.CloseAndFlush(); } } finally { timer.Stop(); AnsiConsole.MarkupLine($"[blue]All completed in [yellow]{timer.ElapsedMilliseconds}[/]ms[/]"); } }
public static T Load <T>(string name) where T : Configuration, new() { var configurationFile = Path.Combine(ConfigurationDirectory, $"{name}.json"); try { if (File.Exists(configurationFile)) { string json = File.ReadAllText(configurationFile); T config = JsonSerializer.Deserialize <T>(json); config.Name = name; config.ConfigurationFile = configurationFile; return(config); } } catch (Exception ex) { AnsiConsole.MarkupLine($"[red][[:cross_mark: Failed to load the configuration file for {name}]][/]"); AnsiConsole.WriteException(ex, ExceptionFormats.ShortenPaths | ExceptionFormats.ShortenTypes | ExceptionFormats.ShortenMethods | ExceptionFormats.ShowLinks); } return(new T() { Name = name, ConfigurationFile = configurationFile }); }
private async Task ListLights(string ip) { try { var lights = await _mediator.Send(new ListLightsQuery { IpAddress = ip, WaitForUserInput = WaitForUserInput }); if (lights.Count() == 0) { AnsiConsole.MarkupLine("[red][[:cross_mark: No lights found.]][/]"); return; } AnsiConsoleHelper.TitleRule(":light_bulb: Scans are complete. Found lights..."); OutputLights(lights); } catch (ArgumentException ae) { AnsiConsole.MarkupLine($"[red][[:cross_mark: {ae.Message}]][/]"); } catch (InvalidOperationException ex) { AnsiConsole.MarkupLine("[red][[:cross_mark: Failed to register with the bridge.]][/]"); AnsiConsole.WriteException(ex, ExceptionFormats.ShortenPaths | ExceptionFormats.ShortenTypes | ExceptionFormats.ShortenMethods | ExceptionFormats.ShowLinks); } }
/// <summary> /// A main function can also take <see cref="CancellationToken"/> which is hooked up to support termination (e.g CTRL+C) /// </summary> /// <param name="branch">The stack's branch we are targeting the generation for</param> /// <param name="interactive">Run the generation interactively, this will ignore all flags</param> /// <param name="download">Whether to download the specs or use an already downloaded copy</param> /// <param name="includeHighLevel">Also generate the high level client (NEST)</param> /// <param name="skipGenerate">Only download the specs, skip all code generation</param> /// <param name="token"></param> /// <returns></returns> private static async Task <int> Main( string branch, bool interactive = false, bool download = false, bool includeHighLevel = false, bool skipGenerate = false , CancellationToken token = default) { Interactive = interactive; try { if (string.IsNullOrEmpty(branch)) { throw new ArgumentException("--branch can not be null"); } await Generate(download, branch, includeHighLevel, skipGenerate, token); } catch (OperationCanceledException) { AnsiConsole.WriteLine(); AnsiConsole.Render(new Rule("[b white on orange4_1] Cancelled [/]").LeftAligned()); AnsiConsole.WriteLine(); return(1); } catch (Exception ex) { AnsiConsole.WriteLine(); AnsiConsole.Render(new Rule("[b white on darkred] Exception [/]") { Alignment = Justify.Left, }); AnsiConsole.WriteLine(); AnsiConsole.WriteException(ex); return(1); } return(0); }
private async Task Set(string ip, bool on, bool off, bool alert, byte?brightness, string color, uint light) { try { var command = new SetLightCommand { IpAddress = ip, On = on, Off = off, Alert = alert, Brightness = brightness, Color = color, Light = light, WaitForUserInput = WaitForUserInput }; await _mediator.Send(command); AnsiConsoleHelper.TitleRule(":light_bulb: Roamer systems dispatched. Lights have been adjusted..."); var lights = await _mediator.Send(new ListLightsQuery { IpAddress = ip, WaitForUserInput = WaitForUserInput }); OutputLights(lights); } catch (ArgumentException ae) { AnsiConsole.MarkupLine($"[red][[:cross_mark: {ae.Message}]][/]"); } catch (InvalidOperationException ex) { AnsiConsole.MarkupLine("[red][[:cross_mark: Failed to register with the bridge.]][/]"); AnsiConsole.WriteException(ex, ExceptionFormats.ShortenPaths | ExceptionFormats.ShortenTypes | ExceptionFormats.ShortenMethods | ExceptionFormats.ShowLinks); } }
private static void BasicExceptionWriting(Exception ex) { AnsiConsole.WriteLine(); AnsiConsole.MarkupLine("[underline green]Basic exception writing :[/]"); AnsiConsole.WriteException(ex); }
public static int RunProcess(ProcessStartInfo startInfo, CancellationToken cancellationToken) { try { using (Process childProcess = new Process()) { childProcess.StartInfo = startInfo; childProcess.EnableRaisingEvents = true; childProcess.Start(); using (cancellationToken.Register(() => { try { childProcess.Kill(); } catch { // . } })) { childProcess.WaitForExit(); return(cancellationToken.IsCancellationRequested ? 1 : childProcess.ExitCode); } } } catch (Exception ex) { AnsiConsole.WriteException(ex); } return(1); }
private static async Task <int> Main() { try { var toolsDirectory = GetToolsDirectory(); foreach (DirectoryInfo dir in toolsDirectory.EnumerateDirectories()) { dir.Delete(true); } var cancellationTokenSource = new CancellationTokenSource(); Console.CancelKeyPress += (_, eventArgs) => { // Try to cancel gracefully the first time, then abort the process the second time Ctrl+C is pressed eventArgs.Cancel = !cancellationTokenSource.IsCancellationRequested; cancellationTokenSource.Cancel(); }; var options = new Options(); var archiveExtractor = new ArchiveExtractor(options); var downloader = new MongoDbDownloader(archiveExtractor, options); await downloader.RunAsync(toolsDirectory, cancellationTokenSource.Token); return(0); } catch (Exception exception) { if (exception is not OperationCanceledException) { AnsiConsole.WriteException(exception, ExceptionFormats.ShortenPaths); } return(1); } }
public static void Exception(Exception ex) { if (Verbose) { AnsiConsole.WriteException(ex); } }
private static void FormattedExceptionWriting(Exception ex) { AnsiConsole.WriteLine(); AnsiConsole.MarkupLine("[underline green]Formatted exception writing :[/]"); AnsiConsole.WriteException(ex, ExceptionFormats.ShortenPaths | ExceptionFormats.ShortenTypes | ExceptionFormats.ShortenMethods | ExceptionFormats.ShowLinks); }
public static void Run(string filePath, string boundedContextDirectory, IFileSystem fileSystem) { try { var template = new Bus(); template.Environments.Add(new ApiEnvironment { EnvironmentName = "Development" }); if (!string.IsNullOrEmpty(filePath)) { FileParsingHelper.RunInitialTemplateParsingGuards(filePath); template = FileParsingHelper.GetTemplateFromFile <Bus>(filePath); } var srcDirectory = Path.Combine(boundedContextDirectory, "src"); var testDirectory = Path.Combine(boundedContextDirectory, "tests"); Utilities.IsBoundedContextDirectoryGuard(srcDirectory, testDirectory); var projectBaseName = Directory.GetParent(srcDirectory).Name; template.ProjectBaseName = projectBaseName; // get solution dir var solutionDirectory = Directory.GetParent(boundedContextDirectory).FullName; Utilities.IsSolutionDirectoryGuard(solutionDirectory); AddBus(template, srcDirectory, testDirectory, projectBaseName, solutionDirectory, fileSystem); WriteHelpHeader($"{Environment.NewLine}Your event bus has been successfully added. Keep up the good work!"); } catch (Exception e) { if (e is InvalidMessageBrokerException || e is IsNotBoundedContextDirectory) { WriteError($"{e.Message}"); } else { AnsiConsole.WriteException(e, new ExceptionSettings { Format = ExceptionFormats.ShortenEverything | ExceptionFormats.ShowLinks, Style = new ExceptionStyle { Exception = new Style().Foreground(Color.Grey), Message = new Style().Foreground(Color.White), NonEmphasized = new Style().Foreground(Color.Cornsilk1), Parenthesis = new Style().Foreground(Color.Cornsilk1), Method = new Style().Foreground(Color.Red), ParameterName = new Style().Foreground(Color.Cornsilk1), ParameterType = new Style().Foreground(Color.Red), Path = new Style().Foreground(Color.Red), LineNumber = new Style().Foreground(Color.Cornsilk1), } }); } } }
public static void Run(string filePath, string domainDirectory, IFileSystem fileSystem, Verbosity verbosity) { try { FileParsingHelper.RunInitialTemplateParsingGuards(filePath); Utilities.SolutionGuard(domainDirectory); var boundedContexts = FileParsingHelper.GetTemplateFromFile <BoundedContextsTemplate>(filePath); WriteHelpText($"Your template file was parsed successfully."); foreach (var template in boundedContexts.BoundedContexts) { ApiScaffolding.ScaffoldApi(domainDirectory, template, fileSystem); } // migrations Utilities.RunDbMigrations(boundedContexts.BoundedContexts, domainDirectory); WriteHelpHeader($"{Environment.NewLine}Your bounded contexts have been successfully added. Keep up the good work!"); StarGithubRequest(); } catch (Exception e) { if (e is FileAlreadyExistsException || e is DirectoryAlreadyExistsException || e is InvalidSolutionNameException || e is FileNotFoundException || e is InvalidDbProviderException || e is InvalidFileTypeException || e is DataValidationErrorException || e is SolutiuonNameEntityMatchException) { WriteError($"{e.Message}"); } else { AnsiConsole.WriteException(e, new ExceptionSettings { Format = ExceptionFormats.ShortenEverything | ExceptionFormats.ShowLinks, Style = new ExceptionStyle { Exception = new Style().Foreground(Color.Grey), Message = new Style().Foreground(Color.White), NonEmphasized = new Style().Foreground(Color.Cornsilk1), Parenthesis = new Style().Foreground(Color.Cornsilk1), Method = new Style().Foreground(Color.Red), ParameterName = new Style().Foreground(Color.Cornsilk1), ParameterType = new Style().Foreground(Color.Red), Path = new Style().Foreground(Color.Red), LineNumber = new Style().Foreground(Color.Cornsilk1), } }); } } }
private static async Task Main(string[] args) { try { await RunAsync(args); } catch (Exception ex) when(!Debugger.IsAttached) { Console.Error.WriteLine("fatal:"); AnsiConsole.WriteException(ex); } }
public static void Exception(Exception ex) { if (Verbose) { AnsiConsole.WriteException(ex); if (!string.IsNullOrEmpty(LogFile)) { File.AppendAllText(LogFile, $"{ex}{Environment.NewLine}"); } } }
public static async Task Main(string[] args) { try { var foo = new List <string>(); DoMagic(42, null, ref foo); } catch (Exception ex) { AnsiConsole.WriteLine(); AnsiConsole.Write(new Rule("Default").LeftAligned()); AnsiConsole.WriteLine(); AnsiConsole.WriteException(ex); AnsiConsole.WriteLine(); AnsiConsole.Write(new Rule("Compact").LeftAligned()); AnsiConsole.WriteLine(); AnsiConsole.WriteException(ex, ExceptionFormats.ShortenEverything | ExceptionFormats.ShowLinks); AnsiConsole.WriteLine(); AnsiConsole.Write(new Rule("Compact + Custom colors").LeftAligned()); AnsiConsole.WriteLine(); AnsiConsole.WriteException(ex, new ExceptionSettings { Format = ExceptionFormats.ShortenEverything | ExceptionFormats.ShowLinks, Style = new ExceptionStyle { Exception = new Style().Foreground(Color.Grey), Message = new Style().Foreground(Color.White), NonEmphasized = new Style().Foreground(Color.Cornsilk1), Parenthesis = new Style().Foreground(Color.Cornsilk1), Method = new Style().Foreground(Color.Red), ParameterName = new Style().Foreground(Color.Cornsilk1), ParameterType = new Style().Foreground(Color.Red), Path = new Style().Foreground(Color.Red), LineNumber = new Style().Foreground(Color.Cornsilk1), } }); } try { await DoMagicAsync <int>(42, null); } catch (Exception ex) { AnsiConsole.WriteLine(); AnsiConsole.Write(new Rule("Async").LeftAligned()); AnsiConsole.WriteLine(); AnsiConsole.WriteException(ex, ExceptionFormats.ShortenPaths); } }
public static void Run(string filePath, string solutionDirectory, IFileSystem fileSystem, Verbosity verbosity) { try { FileParsingHelper.RunInitialTemplateParsingGuards(filePath); var template = FileParsingHelper.GetTemplateFromFile <AddEntityTemplate>(filePath); var srcDirectory = Path.Combine(solutionDirectory, "src"); var testDirectory = Path.Combine(solutionDirectory, "tests"); Utilities.IsBoundedContextDirectoryGuard(srcDirectory, testDirectory); var projectBaseName = Directory.GetParent(srcDirectory).Name; template = GetDbContext(srcDirectory, template, projectBaseName); template.SolutionName = projectBaseName; WriteHelpText($"Your template file was parsed successfully."); FileParsingHelper.RunPrimaryKeyGuard(template.Entities); // add all files based on the given template config RunEntityBuilders(srcDirectory, testDirectory, template, fileSystem); WriteHelpHeader($"{Environment.NewLine}Your entities have been successfully added. Keep up the good work!"); } catch (Exception e) { if (e is IsNotBoundedContextDirectory) { WriteError($"{e.Message}"); } else { AnsiConsole.WriteException(e, new ExceptionSettings { Format = ExceptionFormats.ShortenEverything | ExceptionFormats.ShowLinks, Style = new ExceptionStyle { Exception = new Style().Foreground(Color.Grey), Message = new Style().Foreground(Color.White), NonEmphasized = new Style().Foreground(Color.Cornsilk1), Parenthesis = new Style().Foreground(Color.Cornsilk1), Method = new Style().Foreground(Color.Red), ParameterName = new Style().Foreground(Color.Cornsilk1), ParameterType = new Style().Foreground(Color.Red), Path = new Style().Foreground(Color.Red), LineNumber = new Style().Foreground(Color.Cornsilk1), } }); } } }
public static async Task <EnvironmentCheckResults> ExecuteAllEnvironmentChecks(IServiceProvider services, CancellationToken token = default(CancellationToken)) { var results = new EnvironmentCheckResults(); var checks = services.discoverChecks().ToArray(); if (!checks.Any()) { AnsiConsole.WriteLine("No environment checks."); return(results); } await AnsiConsole.Progress().StartAsync(async c => { var task = c.AddTask("[bold]Running Environment Checks[/]", new ProgressTaskSettings { MaxValue = checks.Length }); for (int i = 0; i < checks.Length; i++) { var check = checks[i]; try { await check.Assert(services, token); AnsiConsole.MarkupLine( $"[green]{(i + 1).ToString().PadLeft(4)}.) Success: {check.Description}[/]"); results.RegisterSuccess(check.Description); } catch (Exception e) { AnsiConsole.MarkupLine( $"[red]{(i + 1).ToString().PadLeft(4)}.) Failed: {check.Description}[/]"); AnsiConsole.WriteException(e); results.RegisterFailure(check.Description, e); } finally { task.Increment(1); } } task.StopTask(); }); return(results); }
public static void Run(string buildSolutionDirectory, IFileSystem fileSystem) { try { var promptResponse = RunPrompt(); var templateString = GetExampleDomain(promptResponse.name, promptResponse.type); var domainProject = FileParsingHelper.ReadYamlString <DomainProject>(templateString); var domainDirectory = $"{buildSolutionDirectory}{Path.DirectorySeparatorChar}{domainProject.DomainName}"; NewDomainProjectCommand.CreateNewDomainProject(domainDirectory, fileSystem, domainProject); ExampleTemplateBuilder.CreateYamlFile(domainDirectory, templateString, fileSystem); AnsiConsole.MarkupLine($"{Environment.NewLine}[bold yellow1]Your example project is project is ready![/]"); StarGithubRequest(); } catch (Exception e) { if (e is FileAlreadyExistsException || e is DirectoryAlreadyExistsException || e is InvalidSolutionNameException || e is FileNotFoundException || e is InvalidDbProviderException || e is InvalidFileTypeException || e is DataValidationErrorException || e is SolutiuonNameEntityMatchException) { WriteError($"{e.Message}"); } else { AnsiConsole.WriteException(e, new ExceptionSettings { Format = ExceptionFormats.ShortenEverything | ExceptionFormats.ShowLinks, Style = new ExceptionStyle { Exception = new Style().Foreground(Color.Grey), Message = new Style().Foreground(Color.White), NonEmphasized = new Style().Foreground(Color.Cornsilk1), Parenthesis = new Style().Foreground(Color.Cornsilk1), Method = new Style().Foreground(Color.Red), ParameterName = new Style().Foreground(Color.Cornsilk1), ParameterType = new Style().Foreground(Color.Red), Path = new Style().Foreground(Color.Red), LineNumber = new Style().Foreground(Color.Cornsilk1), } }); } } }
public void Save() { try { string json = JsonSerializer.Serialize(this, GetType()); File.WriteAllText(ConfigurationFile, json); } catch (Exception ex) { AnsiConsole.MarkupLine($"[red][[:cross_mark: Failed to save the configuration file for {Name}]][/]"); AnsiConsole.WriteException(ex, ExceptionFormats.ShortenPaths | ExceptionFormats.ShortenTypes | ExceptionFormats.ShortenMethods | ExceptionFormats.ShowLinks); } }
private static async Task <int> AnalyzeCommand(IHost host, FileInfo solutionPath, string projectName) { try { return(await AnsiConsole.Progress().AutoClear(false) .Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn(), new ElapsedTimeColumn()). StartAsync(async progressContext => { var logger = host.Services.GetRequiredService <ILogger <Program> >(); var progressSubscriber = new AnsiConsoleProgressSubscriber(progressContext); var workspace = CreateWorkspace(progressSubscriber, logger); var(solution, proj) = await OpenSolutionAndProject(solutionPath, projectName, workspace, progressSubscriber, logger); if (proj == null) { return -1; } progressSubscriber.Report( new FindInternalClassesProgress(FindInternalTypesStep.LoadSolution, 100)); var port = host.Services.GetRequiredService <IFindInternalTypesPort>(); var internalSymbols = await port.FindProjClassesWhichCanBeInternalAsync(solution, proj.Id, progressSubscriber, CancellationToken.None); AnsiConsole.WriteLine($"Found {internalSymbols.Count()} public types which can be made internal"); var table = new Table(); table.AddColumn("№").AddColumn("Type").AddColumn("Location"); var i = 0; foreach (var symbol in internalSymbols) { table.AddRow($"{++i}", $"{symbol.TypeKind} {symbol.Name}", symbol.Locations.FirstOrDefault()?.GetLineSpan().ToString() ?? string.Empty); } AnsiConsole.Render(table); return 0; })); } catch (Exception e) { AnsiConsole.WriteException(e); return(-1); } }
public static void Run(string filePath, string buildSolutionDirectory, IFileSystem fileSystem, Verbosity verbosity) { try { FileParsingHelper.RunInitialTemplateParsingGuards(filePath); var domainProject = FileParsingHelper.GetTemplateFromFile <DomainProject>(filePath); WriteLogMessage($"Your template file was parsed successfully"); var domainDirectory = $"{buildSolutionDirectory}{Path.DirectorySeparatorChar}{domainProject.DomainName}"; CreateNewDomainProject(domainDirectory, fileSystem, domainProject); AnsiConsole.MarkupLine($"{Environment.NewLine}[bold yellow1]Your domain project is ready! Build something amazing. [/]"); StarGithubRequest(); } catch (Exception e) { if (e is FileAlreadyExistsException || e is DirectoryAlreadyExistsException || e is InvalidSolutionNameException || e is FileNotFoundException || e is InvalidDbProviderException || e is InvalidFileTypeException || e is DataValidationErrorException || e is SolutiuonNameEntityMatchException) { WriteError($"{e.Message}"); } else { AnsiConsole.WriteException(e, new ExceptionSettings { Format = ExceptionFormats.ShortenEverything | ExceptionFormats.ShowLinks, Style = new ExceptionStyle { Exception = new Style().Foreground(Color.Grey), Message = new Style().Foreground(Color.White), NonEmphasized = new Style().Foreground(Color.Cornsilk1), Parenthesis = new Style().Foreground(Color.Cornsilk1), Method = new Style().Foreground(Color.Red), ParameterName = new Style().Foreground(Color.Cornsilk1), ParameterType = new Style().Foreground(Color.Red), Path = new Style().Foreground(Color.Red), LineNumber = new Style().Foreground(Color.Cornsilk1), } }); } } }
internal static void WriteException(SdkToolFailedExitException sdkEx) { foreach (var line in sdkEx.StdErr) { if (line.StartsWith("Picked up JAVA_TOOL_OPTIONS:")) { continue; } AnsiConsole.WriteLine(line); } AnsiConsole.WriteLine(); AnsiConsole.WriteException(sdkEx); }
public bool SaveKey(string key) { try { File.WriteAllText(KeyFilename, key); } catch (Exception ex) { AnsiConsole.MarkupLine("[red][[:cross_mark: Failed to save bridge registration.]][/]"); AnsiConsole.WriteException(ex, ExceptionFormats.ShortenPaths | ExceptionFormats.ShortenTypes | ExceptionFormats.ShortenMethods | ExceptionFormats.ShowLinks); return(false); } return(true); }
private static IEnumerable <KeyValuePair <string, string> > ParseIni(string iniPath) { if (!File.Exists(iniPath)) { throw new FileNotFoundException("Unable to find " + iniPath); } TextReader iniFile = null; var kvpList = new List <KeyValuePair <string, string> >(); try { iniFile = new StreamReader(iniPath); var strLine = iniFile.ReadLine(); while (strLine != null) { if (strLine != "" && strLine.Substring(0, 2) != "//") { var keyValuePair = strLine.Split(new[] { '=' }, 2); var key = keyValuePair[0]; var value = keyValuePair[1]; if (value.Contains("//")) { value = value.Split(new[] { '/' }, 2).First(); } var nameValuePair = new KeyValuePair <string, string>(key.Trim(' '), value.Trim(' ')); kvpList.Add(nameValuePair); } strLine = iniFile.ReadLine(); } return(kvpList); } catch (Exception ex) { AnsiConsole.WriteException(ex); throw; } finally { iniFile?.Close(); } }
public override int Execute([NotNull] CommandContext context, [NotNull] AvdStartCommandSettings settings) { var ok = true; try { var emu = new Emulator(settings?.Home); Emulator.AndroidEmulatorProcess process = null; AnsiConsole.Status() .Start($"Starting {settings.Name}...", ctx => { process = emu.Start(settings.Name, new Emulator.EmulatorStartOptions { WipeData = settings.WipeData, NoSnapshot = settings.NoSnapshot }); var timeout = settings.Timeout.HasValue ? TimeSpan.FromSeconds(settings.Timeout.Value) : TimeSpan.Zero; if (settings.WaitForBoot) { ctx.Status($"Waiting for {settings.Name} to finish booting..."); ok = process.WaitForBootComplete(timeout); } if (settings.WaitForExit) { ctx.Status($"Booted, waiting for {settings.Name} to exit..."); ok = process.WaitForExit() == 0; } }); if (!ok) { AnsiConsole.WriteException(new Exception("Failed to start AVD: " + string.Join(Environment.NewLine, process.GetStandardOutput()))); } } catch (SdkToolFailedExitException sdkEx) { Program.WriteException(sdkEx); return(1); } return(ok ? 0 : 1); }
private static void Main(string[] args) { try { Utils.ShowLogo(); AnsiConsole.MarkupLine("[yellow]Initializing sidebar[/]..."); Init(); Build(); AnsiConsole.MarkupLine("[green]Done![/]"); Console.ReadLine(); } catch (Exception e) { AnsiConsole.WriteException(e); Console.ReadLine(); } }
private bool ParseIndex() { var indexParsed = false; try { indexParsed = int.TryParse(_data[0], out _index); } catch (Exception ex) { AnsiConsole.WriteException(ex); } _dataCount = _data.Length; return(indexParsed && (_dataCount is 2 or 7)); }
internal static Command Create() { var deploymentCommand = new Command("deployment") { new Option <string>("--apiKey", description: "An API key with permission to execute the command") { IsRequired = true, }, new Option <string>("--version", "The version number of this deployment") { IsRequired = true, }, new Option <DateTime>("--created", "When was this deployment created in UTC"), new Option <string>("--description", "Description of this deployment"), new Option <string>("--userName", "The name of the person responsible for creating this deployment"), new Option <string>("--userEmail", "The email of the person responsible for creating this deployment"), new Option <Guid>("--logId", "The ID of a log if this deployment is specific to a single log"), }; deploymentCommand.Description = "Create a new deployment"; deploymentCommand.Handler = CommandHandler.Create <string, string, DateTime?, string, string, string, Guid?>((apiKey, version, created, description, userName, userEmail, logId) => { var api = Api(apiKey); try { var result = api.Deployments.Create(new Client.CreateDeployment { Version = version, Created = created, Description = string.IsNullOrWhiteSpace(description) ? null : description, UserName = string.IsNullOrWhiteSpace(userName) ? null : userName, UserEmail = string.IsNullOrWhiteSpace(userEmail) ? null : userEmail, LogId = logId.HasValue ? logId.Value.ToString() : null, }); AnsiConsole.MarkupLine($"[#0da58e]Deployment successfully created[/]"); } catch (Exception e) { AnsiConsole.WriteException(e); } }); return(deploymentCommand); }
public Task StartAsync(CancellationToken cancellationToken) => AnsiConsole.Status().StartAsync("Connecting to server", async ctx => { ctx.Spinner(Spinner.Known.Dots); ctx.Status = "Connecting..."; await Client.Connect(async error => { AnsiConsole.MarkupLine("[bold red]Error:[/] error connecting to server!"); AnsiConsole.WriteException(error); ctx.Status = "Waiting to retry..."; await Task.Delay(TimeSpan.FromSeconds(2)); ctx.Status = "Retrying connection..."; return(true); }); ctx.Status = "Connected!"; });
public override int Execute(CommandContext context) { var appSettings = AppSettings.LoadFromFile(); try { var cvrSystemHelper = new CvrSystemWrapper(EVRApplicationType.VRApplication_Utility); var vrApplicationError = cvrSystemHelper.CvrApplications.RemoveApplicationManifest(Path.GetFullPath(appSettings.ApplicationManifestPath)); AnsiConsoleHelper.MarkupLine(appSettings.LanguageDataSet.GetValue(vrApplicationError == EVRApplicationError.None ? nameof(LanguageDataSet.StreamVRRemoveManifestSuccess) : nameof(LanguageDataSet.StreamVRRemoveManifestFailure)), vrApplicationError == EVRApplicationError.None ? AnsiConsoleHelper.State.Success : AnsiConsoleHelper.State.Failure); } catch (Exception ex) { AnsiConsoleHelper.MarkupLine(appSettings.LanguageDataSet.GetValue(nameof(LanguageDataSet.StreamVRRemoveManifestFailure)), AnsiConsoleHelper.State.Failure); AnsiConsole.WriteException(ex); return(1); } return(0); }