Skip to content

Incorrect handling of subcommands with the same argument #67

@ad-si

Description

@ad-si

Given following program:

data Cli
  = Serve { filePath :: FilePath }
  | Inspect { filePath :: FilePath }
  deriving (Show, Data, Typeable)

cliServe :: Cli
cliServe = Serve { filePath = def &= typ "Path to file" &= args }

cliInspect :: Cli
cliInspect = Inspect { filePath = def &= typ "Path to file" &= args }

Executing it leads to this help text:

 $ stack run -- --help
The cli program

cli [COMMAND] ... [OPTIONS]

Common flags:
  -? --help           Display help message
  -V --version        Print version information

cli serve [OPTIONS] [Path to file]

cli inspect [OPTIONS]

  -f --filepath=ITEM

For serve it gets parsed as a normal argument and for inspect as a flag.

When I change the typ of one of them to something else, it works. 😳

This also happens when I remove both typ expressions, since the name then seems to default to ITEM.

This can't be right, can it?

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