clap-st icon indicating copy to clipboard operation
clap-st copied to clipboard

Specify short form of CLAP flag, when having multiple flags starting with same letter

Open Bajger opened this issue 4 years ago • 2 comments

Enhance ClapFlag with option to specify short form of flag name.

Describe the request Currently, short form ClapFlag instance is always represented by first letter of long version name. This causes a problem, when having multiple flags starting with same letter, e.g. noHeader and name. There should be an option to specify short name programmatically (when specifying command) in order to avoid name conficts.

Expected behavior

(ClapFlag id: #name)
	description: 'Name description.';
        shortName: 'n';

...
(ClapFlag id: #noHeader)
	description: 'No header description.';
        shortName: 'h';

Expected development cost

  • Add instance variable on ClapFlag class and setter method.
  • Modify shortName getter method to access instance variable and assign first letter substring in initialize method (or lazy assignment).

Version information:

  • reported on CLAP version: https://github.com/pharo-contributions/clap-st/commit/1163bdebb627eb9c14f79c8e66c1817c842e102c

Bajger avatar Jan 11 '22 10:01 Bajger

👍🏻 I would advise keeping the dash out of the shortName: though. At some point I was thinking of aliases instead of just short/long names, because many commands have synonymous flags, or variants with slight semantic differences like --foo / --no-foo

cdlm avatar Jan 11 '22 11:01 cdlm

I would advise keeping the dash out of the shortName: though.

Got it! Dash removed from example.

Bajger avatar Jan 11 '22 12:01 Bajger