As a developer, I would like to be able to consume the -v or --version flags in my application. I'd prefer that if a script is provided, Deno ignore the version flag and instead pass it on to Deno.args. Currently if I run a script with either flag, Deno prints out its internal version information as if I had run
deno versiondeno --versiondeno -vtest.ts containing the following codeconsole.log(Deno.args);
deno test.ts or deno run test.ts[ "test.ts" ]deno test.ts --versiondeno test.ts -vdeno run test.ts --versiondeno run test.ts -vI also don't like how Deno unexpectedly consumes flags after the script name when it recognises them.
@dev-nicolaos You can currently run deno test.ts -- --version. Anything after -- is strictly passed to the script. (Note that -- is included as an argument.)
The built-in argument passing is pretty bare-bones. Check out https://github.com/denoland/deno_std/blob/master/flags/README.md.
Yeah, we shouldn't do that.
I think any arguments after the script name should be passed to the script even without --. Additionally I think that any arguments before the script name should _not_ be passed to the user script.
A nice thing to keep this convenience might be to remap deno --version (and maybe deno -v) to deno version iff NO other arguments are passed... if you pass a script or anything else then don't do that (and so you'd see the flag to Deno.args).
Using -- to separate deno args and program args can be dangerous. We've run in to some pretty scary situations because of the similar functionality npm has. Here's our example:
We had a deploy script that accepted a --dry-run cli arg. It was usually called with npm run deploy, but someone new to the team accidentally tried to use npm run deploy --dry-run without supplying the --. The command happily deployed our services for real, even though we were expecting it to just do a dry run. It gets even worse when npm scripts need to call other npm scripts. You can end up needing commands like npm run blah -- -- -- --force (or bake the same number of --s into the scripts themselves). If npm had just required that npm args go between npm run and blah, this danger and inconvenience would just disappear. It's too late for npm - if they changed the behaviour now, all sorts of existing scripts would break or subtly change behaviour. Deno is in v0, so can still change!
Should be fixed with #3389 landed
Most helpful comment
Yeah, we shouldn't do that.