Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Refactor CLI flag parsing #2025
This PR closes #1987
Blocked by #2017
I've started out by swapping out
@ry I see that V8 flag logic is pretty obscure, I verified that we could leverage such syntax:
deno --v8-flags=--predictable,--log-instruction-status=1,--single-threaded=/asdf/sadf --allow-all some_script.ts
Unfortunately it has to be written as
2 times, most recently
Mar 31, 2019
@ry I agree it's a bit too bright,
Right now the changes are more-or-less compatible with our current way of handling args. WRT comment in #1987 I understand we want to have:
# new way or parsing args, deno only parses flags appearing # before <entry_point> argument, all the rest is forwarded to Deno.args deno --allow-env --allow-net entry_point.ts arg1 arg2 --another-flag
// entry_point.ts console.log(Deno.args);
This will result in:
Formatting will be done via subcommand:
# before deno --fmt <file>... # after deno fmt <file>...
Last but not least V8 flags handling:
# help for V8 flags # before deno --v8-options # after deno --v8-help # pass flags to V8 deno --v8-options=--predictable,--log-instruction-status=1,--single-threaded --allow-all -D
Does that sound good for you @ry?
Otherwise everything else sounds good. Please prepare a commit message outlining the changes, so I can copy and paste that in when I squash it.
@ry after going back and forth with parsing args I have to propose to go with this method:
USAGE: deno [FLAGS] <script> -- <script_args>...
Which requires passing script arguments after
USAGE: deno [FLAGS] <script> <script_args>...
turns out to be huge PITA, and causing lot of quirks... Eg:
Also I wasn't yet able to force
Dang that sucks. I thought this was one of clap’s features (but now that read back on their documents, I see I had confused it.)
Also the 2 year old open issue for color support isn’t very heartening.
@bartlomieju I haven’t had a chance to really dig into your code yet. What’s your feeling so far? Is this going to be better? Do you think clap is the right choice?
I think treating foo.ts as an ExternalSubcommands ought to work without --.
See re clap maintainer: https://www.reddit.com/r/rust/comments/b575hi/comment/ejdawiv
I can mimic clap's coloring for environment variables section.
@ry PTAL, most of the changes are already there, there are two more things I want to do: