shlonka
shlonka
Explore posts from servers
CC#
Created by shlonka on 12/31/2023 in #help
Spectre.Console Status not showing, app seems to stop
I don't have a lot of experience with async/await, and this is my first time using the Spectre.Console and CliWrap libraries, and while they're pretty nice to use, I'm not entirely sure what's going wrong here:
await AnsiConsole.Status().StartAsync("Generating files", async ctx =>
{
ctx.Spinner(Spinner.Known.Ascii);
AnsiConsole.WriteLine("Hey, Wilbrand! Can you help me out real quick?");
var result = await Cli.Wrap(Path.Join(Directory.GetParent(Environment.ProcessPath).FullName, "/extra/wilbrand"))
.WithArguments(new[] { macaddr, DateTime.Now.ToShortDateString(), version, sd })
.ExecuteBufferedAsync(); //program seems to exit here? no more prints after this
if (result.StandardError == "") {
AnsiConsole.WriteLine("Thanks bro!");
} else {
AnsiConsole.MarkupLine("[red]It's alright if you messed up, you tried your best.[/]\n\n[red dim]Try again, maybe?[/]");
Environment.Exit(1);
}
AnsiConsole.Markup($"[grey dim italics]{result.StandardOutput}");
});
AnsiConsole.MarkupLine("[bright green]Done! Check your SD card for a surprise ;)");
await AnsiConsole.Status().StartAsync("Generating files", async ctx =>
{
ctx.Spinner(Spinner.Known.Ascii);
AnsiConsole.WriteLine("Hey, Wilbrand! Can you help me out real quick?");
var result = await Cli.Wrap(Path.Join(Directory.GetParent(Environment.ProcessPath).FullName, "/extra/wilbrand"))
.WithArguments(new[] { macaddr, DateTime.Now.ToShortDateString(), version, sd })
.ExecuteBufferedAsync(); //program seems to exit here? no more prints after this
if (result.StandardError == "") {
AnsiConsole.WriteLine("Thanks bro!");
} else {
AnsiConsole.MarkupLine("[red]It's alright if you messed up, you tried your best.[/]\n\n[red dim]Try again, maybe?[/]");
Environment.Exit(1);
}
AnsiConsole.Markup($"[grey dim italics]{result.StandardOutput}");
});
AnsiConsole.MarkupLine("[bright green]Done! Check your SD card for a surprise ;)");
The status doesn't even show up, no spinner or anything, and the final print is "Hey, Wilbrand! Can you help me out real quick?" despite the Cli.Wrap working successfully, as the files are generating properly. Also, is there a more proper way of getting the path of the program other than Environment.ProcessPath? It feels like the ProcessPath has a chance to report a different path if the app is run a different way, like through a different CLI. I'm on Linux .NET 8 if that helps. Just getting back into C# after an extended break
1 replies