Skip to content

Flags not parsed when additional args are provided #11

@Wulfheart

Description

@Wulfheart

Example:

package main

import (
	"fmt"
	"github.com/leaanthony/clir"
)

func main() {
	cli := clir.NewCli("test", "Test", "v0.0.0")
	s := cli.NewSubCommand("sub", "Desc")
	var f string
	s.StringFlag("f", "De", &f)
	s.Action(func() error {
		fmt.Println(f)
		return nil
	})
	cli.Run()
}

Command

go run main.go sub file -help

Expected output

test v0.0.0 - Test

test sub - Desc
Flags:

  -f string
        De
  -help
        Get help on the 'test sub' command.

Actual output


Update

It seems that if the additional argument is provided after the flags it just works fine. However I don't consider this a viable solution. Now I can see some parallels to #9.


I am going to address this in 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