launchrctl / launchr

Launchr is a CLI action runner that executes actions inside short-lived local containers.
Apache License 2.0
10 stars 2 forks source link

Arguments are not explained in action --help #6

Open davidferlay opened 9 months ago

davidferlay commented 9 months ago

Context

Observed

Flags: -h, --help help for platform:compare-artifact --overriden_comparison_ref string Overriden comparison reference (branch or tag name)

Global Flags: --keyring-passphrase string Passphrase for keyring encryption/decryption -q, --quiet disable stdOut -v, --verbose count log verbosity level, use -vvv DEBUG, -vv WARN, -v INFO



## Expected

- Both options and arguments should be listed in --help of actions
iignatevich commented 9 months ago

doesn't look doable

launchr is based on cobra commands and they don't support --help for arguments https://github.com/spf13/cobra/issues/571 maximum we can add right now is sorta validation function with more description

like

ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
        var comps []string
        if len(args) == 0 {
            comps = cobra.AppendActiveHelp(comps, "You must choose a name for the repo you are adding")
        } else if len(args) == 1 {
            comps = cobra.AppendActiveHelp(comps, "You must specify the URL for the repo you are adding")
        } else {
            comps = cobra.AppendActiveHelp(comps, "This command does not take any more arguments")
        }
        return comps, cobra.ShellCompDirectiveNoFileComp
    },
lexbritvin commented 9 months ago

We may implement through custom templates. I had some plans for it. Come to me for details.

davidferlay commented 9 months ago

Why not contribute it to cobra istead ?