jwaldrip / admiral.cr

A robust DSL for writing command line interfaces written in Crystal.
https://jwaldrip.github.com/admiral.cr
MIT License
135 stars 14 forks source link

Ability to remove parsed parts #9

Closed docelic closed 4 years ago

docelic commented 6 years ago

Hey,

If one defines some flags and arguments, like: define_flag a define_flag b define_argument c

Then upon calling: cmd subcmd -a one -b two three four

It would be great if there was a way to automatically remove parsed parts out of ARGV or original array, so that only "four" remains in it.

Currently, it appears as if original contents are never modified.

jwaldrip commented 6 years ago

We don't ever modify ARGV, but you can call any Enumerable on arguments or call arguments[i] to get the remaining args.

filleduchaos commented 6 years ago

Hi,

Seconding removing parsed parts from ARGV. I just ran into an annoying bug with that this morning - I'm working on a command line tool that (amongst other things) starts a Kemal server via a subcommand, and Kemal.run trips on the flags/arguments left over from the CLI. As a workaround I've been modifying ARGV myself, but honestly it's a bit ugly. It would be nice if Admiral had that built in (even if disabled by default) because in its current state it's a bit incompatible with other shards that use OptionParser.