Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Status StartAsync stopping program, not working #1418

Closed
ghost opened this issue Dec 31, 2023 · 0 comments
Closed

Status StartAsync stopping program, not working #1418

ghost opened this issue Dec 31, 2023 · 0 comments

Comments

@ghost
Copy link

ghost commented Dec 31, 2023

Information

  • OS: Linux
  • Version: 0.48.0
  • Terminal: VSCode Integrated terminal / Alacritty

Describe the bug
While trying to run AnsiConsole.Status().StartAsync(), the spinner doesn't show up, and after a CliWrap function finishes executing, the program exits with no exceptions or prints, despite there being more prints inside the Status function, as well as outside of it.

To Reproduce
Add latest CliWrap and Spectre.Console packages to a .NET 8 project. In a separate function that is called from Main(), put

        var output = await AnsiConsole.Status().StartAsync("Generating files", async ctx =>
        {  
            ctx.Spinner(Spinner.Known.Ascii);
            AnsiConsole.WriteLine("Hey, Wilbrand! Can you help me out real quick?");
            BufferedCommandResult? result = null;
            try {
                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
            } catch (Exception e) {
                AnsiConsole.WriteLine(e.ToString());
            }
            
            await Task.Delay(5000);
            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);
            }
            return result.StandardOutput;
        });
        AnsiConsole.Markup($"[grey dim italics]{output}");
        AnsiConsole.MarkupLine("[bright green]Done! Check your SD card for a surprise ;)");

And then run the program, with macaddr, version, and sd variables being strings.
Expected behavior
A spinner to appear as the external program is run, then the output of the program to be printed in the console, as well as the three prints that come after the CliWrap function.

Screenshots
image

Additional context
N/A

@ghost ghost added bug Something isn't working needs triage labels Dec 31, 2023
@github-project-automation github-project-automation bot moved this to Todo 🕑 in Spectre Console Dec 31, 2023
@spectreconsole spectreconsole locked and limited conversation to collaborators Jan 1, 2024
@nils-a nils-a converted this issue into discussion #1420 Jan 1, 2024
@github-project-automation github-project-automation bot moved this from Todo 🕑 to Done 🚀 in Spectre Console Jan 1, 2024
@nils-a nils-a added moved to discussion and removed bug Something isn't working needs triage labels Jan 1, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
Status: Done 🚀
Development

No branches or pull requests

1 participant