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

"Unknown Syntax Error: Command not found" when running a command with a required param missing #136

Open
jakub-g opened this issue Nov 23, 2022 · 1 comment

Comments

@jakub-g
Copy link
Contributor

jakub-g commented Nov 23, 2022

This is a followup of #101 (see my comment)

When the command yarn cli foo has a required param

name = Option.String('--name', { required: true });

and it's run without it, the error message is not great

yarn cli foo       
Unknown Syntax Error: Command not found; did you mean:

$ yarn cli foo <--name #0>
While running foo

I think in this case, the behavior should be the same as if yarn cli foo --help.

@SeinopSys
Copy link

SeinopSys commented Jun 21, 2023

In my case there was an accidental lack of space between two arguments, e.g. --foo opt1--baz opt2 which lead to a similar message despite both --foo and --baz being optional. The error message was basically 2 of the same alternate options:

Unknown Syntax Error: Command not found; did you mean one of:

  0. /usr/local/bin/node /home/user/index.js my-command [--foo #0] [--baz #0]
  1. /usr/local/bin/node /home/user/index.js my-command [--foo #0] [--baz #0]

Edit: Turns out the issue was a red herring, the CLI abstraction I was using passed a Bash substitution argument as a literal. I verified this by logging process.argv and saw […, '--baz $(cat', 'file.txt)'] in the value received by the script. I adjusted the code to accept the file name as parameter directly without having the command interpreter reading it and it's working well since.

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

No branches or pull requests

2 participants