Skip to content

Parent arguments are not handled when a sub command is defined #21

Description

@b3j0f

Hello, I already fix this issue in a dedicated PR

Describe the bug
When I define a command argument and a sub command, my argument is never handled.

To Reproduce

package main

import (
    "fmt"
    "github.com/hellflame/argparse"
)

func main() {
    parser := argparse.NewParser("basic", "this is a basic program", nil)
    name := parser.String("n", "name", nil)
    subcmd := parser.AddCommand("a", "", nil)
    if e := parser.Parse([]string{"-n", "world", "a"}); e != nil {
        fmt.Println(e.Error())
        return
    }
    fmt.Printf("hello %s\n", *t)
}

Expected behavior
Must display "hello world"

Terminal Output

hello

Environment:

  • OS: MacOS 10.15
  • Go Version: 1.13
  • Package Version: v1.10.0

Resolution

I provided those two pull requests #19 & #20 which respectively solve my case and test the bugfix.

Regards

Additional context

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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