Skip to content

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

Closed
@b3j0f

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

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