coder / serpent

CLI framework for scale and configurability inspired by Cobra
Creative Commons Zero v1.0 Universal
6 stars 1 forks source link

Enforce usage as per Use string #4

Open ammario opened 3 months ago

ammario commented 3 months ago

E.g., in coder/coder we have code like:

    cmd := &serpent.Cmd{
        Use:   "create [name]",
        Short: "DEPRECATED: Create a template from the current directory or as specified by flag",
        Middleware: serpent.Chain(
            serpent.RequireRangeArgs(0, 1),
            r.InitClient(client),
        ),

where the serpent.RequireRangeArgs(0, 1) is arguably redundant with the Use. Also, we could provide an error message by just parsing Use.