Skip to content

Possible bug with option specs #114

@skyzyx

Description

@skyzyx

I've discovered something which violates the Principle of Least Surprise and think that it may be a bug.

I have a spec which looks like this:

cmd.Spec = `[--cluster=<value> [--only-env=<value>] | --all]`

When I run the command with an option, I get the following:

$ mkit module newrelic plan --all
Error: incorrect usage

Usage: mkit module newrelic plan [--cluster=<value> [--only-env=<value>] | --all]

Executes `terraform plan` for the specified Terraform module.

Options:
  -c, --cluster    The friendly name of the cluster that you want to execute against. (Not compatible with --all.)
  -e, --only-env   Used for limiting the execution to a single environment. (Not compatible with --all; requires --cluster.)
  -a, --all        Execute for all clusters at once. (Not compatible with --cluster.)

However, if I reverse the top level options in a way that is semantically identical:

cmd.Spec = `[--all | --cluster=<value> [--only-env=<value>]]`

…it works without issue.

I've read through the text about this in the README, and I didn't find this specifically called-out. As a result, I think it's a parser issue. It's taking position into account in a place where it shouldn't.

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