Skip to content

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

@jinwoo

Description

@jinwoo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions