Skip to content

Usage text for subcommands doesn't display arguments for parents #296

@idloquy

Description

@idloquy

Currently, when subcommands are defined alongside normal arguments, the arguments for parent commands aren't listed in the usage text for the subcommand.

Example:

package main

import (
        "fmt"

        "github.com/alexflint/go-arg"
)

type BarCmd struct {
        Baz string
}

type Args struct {
        Foo string
        Bar *BarCmd `arg:"subcommand:bar"`
}

func main() {
        var args Args
        if err := arg.MustParse(&args); err != nil {
                fmt.Println(err)
                return
        }
}

When this is called as ./args bar --help, the usage text looks like:

Usage: args bar [--baz BAZ]

However, in several cases, one would want it to look like:

Usage: args [--foo FOO] bar [--baz BAZ]

Is this the intended behavior? If not, I'd be happy to open a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions