Skip to content
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

In NimScript mode, make commandLineParams() more useful #23554

Open
jinwoo opened this issue Apr 30, 2024 · 0 comments
Open

In NimScript mode, make commandLineParams() more useful #23554

jinwoo opened this issue Apr 30, 2024 · 0 comments

Comments

@jinwoo
Copy link

jinwoo commented Apr 30, 2024

Summary

cmdline/commandLineParams() (and the parseopt module) is not very friendly with NimScript mode

Description

Currently, when nim is invoked in script mode, cmdline.commandLineParams() returns all the parameters including the flags/arguments that are passed to the nim compiler. For example, with this script (say test.nims):

#!/usr/bin/env -S nim e --hints:off

import std/cmdline

echo "params: ", commandLineParams()

invoking the script via $ ./test.nims foo bar outputs

params: @["e", "--hints:off", "./test.nims", "foo", "bar"]

Ideally I hope it only returns @["foo", "bar"], ignoring the first 3 parameters.

This is annoying because the script needs to ignore the first three parameters to parse correctly. It's more annoying because the number of parameters to ignore depends on what flags/arguments that I pass to nim.

And this makes it very difficult to use the same code both in script mode and in compile mode.

Can it be made so that the script mode strips out the parameters that are passed to nim

Alternatives

No response

Examples

No response

Backwards Compatibility

No response

Links

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant