-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
cli: fix help message #9842
cli: fix help message #9842
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can confirm that the help message is fixed by this change:
theia --help
displays all commands as well as general arguments (--help
,--version
,--app-target
) ✔️theia generate --help
shows the command parameters for generate (--mode
and--split-frontend
) ✔️theia <command> --help
shows a general description of every command ✔️- The message for running an unknown command was improved from
non-existing or no command specified
toUnknown command: <command>
✔️ - Every command still runs as expected (as far as I can tell) ✔️
Code LGTM as well, except for one exception, see below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirmed that the cli now displays the proper information:
gitpod /workspace/theia/examples/browser $ yarn theia --help
yarn run v1.22.10
$ /workspace/theia/node_modules/.bin/theia --help
theia <command>
Commands:
theia start Start the browser backend
theia clean Clean for the browser target
theia copy Copy various files from `src-gen` to `lib`
theia generate Generate various files for the browser target
theia build Generate and bundle the browser frontend using webpack
theia rebuild rebuild native node modules for the browser
theia rebuild:browser rebuild native node modules for the browser
theia rebuild:electron rebuild native node modules for the electron
theia check:hoisted Check that all dependencies are hoisted
theia download:plugins Download defined external plugins
Options:
--help Show help [boolean]
--version Show version number [boolean]
--app-target The target application type. Overrides `theia.target` in the
application's package.json [choices: "browser", "electron"]
Done in 0.54s.
gitpod /workspace/theia/examples/browser $ yarn theia start --help
yarn run v1.22.10
$ /workspace/theia/node_modules/.bin/theia start --help
theia start
Start the browser backend
Options:
--help Show help [boolean]
--version Show version number [boolean]
--app-target The target application type. Overrides `theia.target` in the
application's package.json [choices: "browser", "electron"]
Done in 0.88s.
I confirmed it works in electron
as well:
gitpod /workspace/theia/examples/electron $ yarn theia --help
yarn run v1.22.10
$ /workspace/theia/node_modules/.bin/theia --help
theia <command>
Commands:
theia start Start the electron backend
theia clean Clean for the electron target
theia copy Copy various files from `src-gen` to `lib`
theia generate Generate various files for the electron target
theia build Generate and bundle the electron frontend using
webpack
theia rebuild rebuild native node modules for the electron
theia rebuild:browser rebuild native node modules for the browser
theia rebuild:electron rebuild native node modules for the electron
theia check:hoisted Check that all dependencies are hoisted
theia download:plugins Download defined external plugins
Options:
--help Show help [boolean]
--version Show version number [boolean]
--app-target The target application type. Overrides `theia.target` in the
application's package.json [choices: "browser", "electron"]
Done in 0.45s.
Did you mean to fail it for an unknown command? (it does fail without the --help
flag)
gitpod /workspace/theia/examples/browser $ yarn theia vince --help
yarn run v1.22.10
$ /workspace/theia/node_modules/.bin/theia vince --help
theia <command>
Commands:
theia start Start the browser backend
theia clean Clean for the browser target
theia copy Copy various files from `src-gen` to `lib`
theia generate Generate various files for the browser target
theia build Generate and bundle the browser frontend using webpack
theia rebuild rebuild native node modules for the browser
theia rebuild:browser rebuild native node modules for the browser
theia rebuild:electron rebuild native node modules for the electron
theia check:hoisted Check that all dependencies are hoisted
theia download:plugins Download defined external plugins
Options:
--help Show help [boolean]
--version Show version number [boolean]
--app-target The target application type. Overrides `theia.target` in the
application's package.json [choices: "browser", "electron"]
Done in 0.63s.
A similar yarn
command does:
gitpod /workspace/theia/examples/electron $ yarn vince --help
yarn run v1.22.10
error Command "vince" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@vince-fugnitto I tried addressing your suggestion about invalid commands followed by |
The CLI parsing logic is broken in `@theia/cli`. The help doesn't show the right information. The issue comes from using `yargs` at the script level in some places, leading to corrupt global `yargs` state. This commit refactors code around so that `--help` works as expected.
4e6e7a3
to
ff48649
Compare
I just polished the async queue a bit and fixed CI, turns out the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirmed under different conditions that the --help
displays correctly 👍
I believe it fixes the long standing issue #1902.
#1902 wasn't fixed, but I just pushed a commit that fixes it. The issue is that doing |
50f2101
to
136c414
Compare
136c414
to
ccea62f
Compare
The CLI parsing logic is broken in `@theia/cli`. The help doesn't show the right information. The issue comes from using `yargs` at the script level in some places, leading to corrupt global `yargs` state. This commit refactors code around so that `--help` works as expected. `theia start --help` now display's the target application's CLI help rather than `theia`'s help.
The CLI parsing logic is broken in
@theia/cli
. The help doesn't showthe right information.
The issue comes from using
yargs
at the script level in some places,leading to corrupt global
yargs
state.This commit refactors code around so that
--help
works as expected.Fixes #1902
How to test
yarn
cd examples\browser
yarn theia --help
ornpx theia --help
should display a lot of commands, not just a few parameters.yarn theia <command> --help
should display help for that command.yarn theia patate
should fail with "unknown command" (code 1).Review checklist
Reminder for reviewers