Skip to content

Add a -- to mark the end of switches and the start of remaining args to just pass through #3

@azimux

Description

@azimux

Hey hey!

I'd be interested in adding a feature that let's one do something like --foo bar -- args --to pass through

This would result in an argv of ["--foo", "bar", "--", "args", "--to", "pass", "through"] which OptParser#parse would parse into { foo: "bar" } as expected but would give an added method called maybe post_switch_argv or pass_through_argv or something similar which would be kind of like OptParser#tail.

One thing I'd be scared of though is backwards compatibility. If somebody is already implementing -- on their end then this could very well break their code. However, I'm curious how this would even be successfully implemented today. One approach might be parser.on("", but reading the code I feel like this wouldn't entirely give the desired behavior particularly in the example I gave above.

But yeah, would be fun for me to take a swing at if that seems OK. If not due to fear of potentially breaking backward-compatibility or complexity or out of alignment with the project's goals/philosophy, or maybe it's already doable but I'm overlooking how to do it, then feel free of course to close this issue. Otherwise I'll take a swing at it and open a PR if I'm able to make it work!

Cheers!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions