-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Rewrite flags.rs::parse_flags #2227
Comments
SGTM |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With recent numerous changes to CLI and more to come (#2213, #2215) I found myself in situation when it's harder and harder to properly test CLI parsing logic and not break anything.
That's why I'd like to propose yet another rewrite to:
deno/cli/flags.rs
Line 134 in 40d8ef1
Currently it only returns
DenoFlags
and choosing the actual subcommand and construction of argument array that is passed to script in done inmain.rs
. That's not elegant, and logic is split into multiple files and makes it impossible to properly test all entry points.As previously suggested in #2157 it should be
flags_from_vec
that is only public function inflags.rs
that takes care of parsing of CLI flags and choosing appropriate action.So my proposition is to change what's returned from this function to:
Then we'll be able to nicely test everything:
With
DenoSubcommand
there will be simplematch
on it inmain.rs
that basically selects function to call, asDenoFlags
and scriptargs
will be already parsed.CC @ry
The text was updated successfully, but these errors were encountered: