Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support documentation for strict = false command arguments #234

Closed
mattgibson opened this issue May 13, 2019 · 4 comments · Fixed by oclif/core#1003
Closed

Support documentation for strict = false command arguments #234

mattgibson opened this issue May 13, 2019 · 4 comments · Fixed by oclif/core#1003

Comments

@mattgibson
Copy link

Do you want to request a feature or report a bug?

Feature.

What is the current behavior?

If I specify strict = false and use argv to access whatever variable length string of arguments the user provides, there is no way to document this. The README doesn't mention that there is an arbitrary list of arguments accepted and if I specify this manually by editing the command form e.g.

USAGE
  $ fd start [SERVICES...]

ARGUMENTS
  SERVICES...  a list of service names

Then it gets overwriten next time I run npx oclif command to add a new one.

What is the expected behavior?

(@oclif/command@1.5.13 on macOS) That I can add documentation similar to that for flags with multiple arguments, which will show up in the README and when using the --help flag.

@xavdid
Copy link

xavdid commented Nov 18, 2019

@mattgibson did you find a solution to this? My only idea right now is to declare the optional arg and then try and parse it out. I've got the following:

export class MyCLI extends Command {
  static strict = false

  static args = [
    {name: 'firstArg', required: true},
    {name: 'secondArg'},
  ]

  async run() {
    this.log(this.args)
    this.log(this.argv)
  }
}

expected:

$ mycli a b c
{ firstArg: 'a', secondArg: [ 'b', 'c' ] }
[ 'a', 'b', 'c' ]

actual:

$ mycli a b c
{ firstArg: 'a', secondArg: 'b' }
[ 'a', 'b', 'c' ]

If I leave off secondArg, then it doesn't show up in --help, which is a bummer.

cc @RasPhilCo

@RasPhilCo
Copy link
Contributor

Added an issue in plugin-help to have it there also.

@xavdid looks like the parser could handle that more clearly, but I'll have to dig in deeper.

@xavdid
Copy link

xavdid commented Nov 18, 2019

Thanks a bunch! let me know if there's anything I can do to help

@aexvir
Copy link

aexvir commented Nov 3, 2020

any update on this?

@mdonnalley mdonnalley closed this as not planned Won't fix, can't repro, duplicate, stale Aug 16, 2022
@oclif oclif deleted a comment from 0xdevalias Mar 5, 2024
@mdonnalley mdonnalley reopened this Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants