#Progrock

1 messages · Page 1 of 1 (latest)

magic tide
#

@ancient edge, if I have a cobra command that returns cmd.Help() from RunE, how do I properly show it in progrock?

ancient edge
#

@magic tide you'll need to make a vertex for the output to be sent to, something like this but maybe less unnecessarily golfed:

fmt.Fprint(progrock.FromContext(ctx).Vertex("bogus-id", "command to show").Stdout(), "hello")
#

we could probably refactor this, right now each command just does its own thing, there might be a good pattern for them to follow

magic tide
#

I'm talking about the usage from --help. Something like this:

    if subCmd.Name() == cmd.Name() {
        return cmd.Help()
    }

    if help, _ := flags.GetBool("help"); help {
        return cmd.Help()
    }

cmd.Help() returns an error with the help message. Cobra catches that, prints it and exits the command, which breaks progrock. Any suggestion on how to handle showing the command usage?

humble panther
#

Not sure if helpful, but back in project commands the relevant code was https://github.com/sipsma/dagger/blob/d505077757b9dab8293a828a292a96f1bc8929d4/cmd/dagger/do.go#L265 and https://github.com/sipsma/dagger/blob/d505077757b9dab8293a828a292a96f1bc8929d4/cmd/dagger/do.go#L97-L115

I think you would just need cmd Stdout+Stderr to be hooked up to the progrock vtx, then when you call e.g. cmd.Printf it should be displayed as expected

GitHub

A portable devkit for CI/CD pipelines. Contribute to sipsma/dagger development by creating an account on GitHub.