-
-
Notifications
You must be signed in to change notification settings - Fork 52
cli: validate commands #700
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
base: main
Are you sure you want to change the base?
Conversation
Bumped babashka.cli to get fix for table formatting. Squint has a couple of cli oddities: - `compile` command does not have to be specified for compile - `-e` acts like a command but looks like an option I added upfront processing so these oddities become normal commands for babashka.cli. Changes: - Any unrecognized option is a validation error - Any missing required option is a validation error - An invalid number of args is a validation error - On validation error squint exits with code 1 - `nrepl-server` is now described/exposed - `compile` `:copy-resources` option is now described/exposed - `-e` `--repl` option is now described/exposed - `run` now exposes/describes options, same as `compile` but without `--paths` and `copy-resources` - Usage for `watch` is same as `compile` except `:paths` is required - Added a few cli sanity tests Closes squint-cljs#691
* upstream/main: Fix squint-cljs#697 (squint-cljs#699) Fix typo in resource copy log line (squint-cljs#698)
|
I think this change is finally ready for your review @borkdude! It is on the larger side, so, as usual, when you find time/interest. Happy to answer questions and refine if needed. |
|
Oh yeah, also:
|
|
One thought about the ANSI output. When you pipe the output to a text file you see this: �[31mERROR�[0m: Unrecognized option: --xrepl Is that a problem? ANSI output only makes sense on the terminal. I have an open issue about detecting "terminal" here: In jet I detect terminal in a reliable way here: https://github.com/borkdude/jet/blob/master/src-java/org/babashka/CLibrary.java but it can also be done using but perhaps that's just good enough. |
|
Good point on ANSI escapes. Node itself outputs color. Let's see what it does for comparison:
This is written to stderr, if we redirect: The ansi codes are not there. Does it respect NO_COLOR? It does. Maybe supporting |
|
Oh yeah, we're on Node.js, I forgot, this is not babashka, duh! In Node.js you can use this: It will only return |
|
Ah. Great, I'll make use of |
Mimic node. Don't use ANSI colour codes if any true: 1) `NO_COLOR` env var is set 2) not in an interactive terminal (ex. redirecting output)
I remembered incorrectly, ANSI colour codes do work on Cmd and Powershell on Windows.
This was only expressed internally, but needs to be also expressed in the cli so that: - the user can learn what the default is - the cli uses paths itself for compile, so those defaults need to be applied earlier for it. This means squint no longer has any required opts. Supporting code turfed. This also means we no longer have our failure check for both `<files>` and `--paths` being specified for `compile`. Updated usage note to explain how `<files>` overrides `--paths` and `:paths`. This allowed me to turf post-validate supporting code.

Bumped babashka.cli to get fix for table formatting.
Squint has a couple of cli oddities:
compilecommand does not have to be specified for compile-eacts like a command but looks like an optionI added upfront processing so these oddities become normal commands for babashka.cli.
Changes:
nrepl-serveris now described/exposedcompile:copy-resourcesoption is now described/exposed-e--reploption is now described/exposedrunnow exposes/describes options, same ascompilebut without--pathsandcopy-resourceswatchis same ascompileexcept:pathsis requiredCloses #691
Please answer the following questions and leave the below in as part of your PR.
This PR corresponds to an issue with a clear problem statement.
This PR contains a test to prevent against future regressions
I have updated the CHANGELOG.md file with a description of the addressed issue.