vilicvane / clime

⌨ The command-line interface framework for TypeScript.
252 stars 10 forks source link

Add support for multi occurrence options #45

Open ajafff opened 6 years ago

ajafff commented 6 years ago

While trying to port hand-written argument parser, I noticed that there's currently no way to configure an option that may occur multiple times and accumulates the arguments:

grep -e 'foo' -e 'bar'

This is how I'd like this to work:

export class GrepOptions extends Options {
  @param({multi: true}) public e: string[];
}

@command()
export default class extends Command {
  @metadata
  public execute(options: GrepOptions) {
    console.log(options.e); // ['foo', 'bar']
  }
}