-
Notifications
You must be signed in to change notification settings - Fork 0
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
Should argv include runtime parts (binary/script/runtime args)? #3
Comments
I would argue against including "runtime args" (args interpreted by the runtime) in the args exposed to users. My reasoning is that arg parsers are not portable across runtimes otherwise, because invocation may happen in different ways across runtimes. For example, in Node you exec with This is significantly complicated for various reasons:
I think exposed args should be an array of all string arguments intended to be passed to the user code. Runtimes should themselves define what "intended to be passed to the user code" means. In Deno and Node this would mean all flags after |
I agree, although it could possibly also be useful to expose the raw argv or binary path or runtime args somewhere too, just not as the main |
Yeah - I think exposing arg information passed to runtimes is better done in runtime specific APIs that present this as structured data. Otherwise you run into the arg parsing problem anyway |
Some prior discussion in the repo which eventually became node's Fun fact: |
I think that the args API can be separate from the binary path API. For example, see process.execPath which is common when forking the process. |
I agree, I put in the explainer/readme but forgot to put here. It seems best to leave aspects like that intentionally not standardized and allow implementers to do so in their own APIs as they see fit. |
i think it was a silly choice to make i dont think there is any use case in having a standard way to expose runtime args (aka it would be nice to have a way to get the name of the script being run (think help messages that explain a usage like "${arg0} [options]"). i dont know if this situation actually has a good solution right now, i notice |
The intuitive approach is to store the script name in argument zero, similar to Python. It follows the existing conventions. For use cases that don't need it, it is easy to ignore. |
argv
is traditionally all arguments, which would include: runtime binary, script being ran, and runtime arguments ("runtime parts"). Should ours?Existing examples:
process.argv
(Node): includes runtime partsDeno.args
(Deno): does not include runtime parts (they can be got separately withDeno.execPath()
, etc)The text was updated successfully, but these errors were encountered: