SamuelSchlesinger / commander-cli

A simple library I wrote to allow me to quickly and easily construct command line interfaces.
MIT License
29 stars 2 forks source link

combined flags #24

Closed BebeSparkelSparkel closed 1 year ago

BebeSparkelSparkel commented 3 years ago

Allow combined flags like with ls

ls [-1AaCcdFfgHhikLlmnopqRrSsTtux] [file ...]

Some questions that need answering.

SamuelSchlesinger commented 3 years ago

I'm not sure of how I feel about this. If it can be implemented clearly and well-documented, the more features the better, but if it adds confusion or indirection to the extant code, I will be anti.

BebeSparkelSparkel commented 3 years ago

This is a tricky one. I don't really like learning them but as a power user they are very helpful.

SamuelSchlesinger commented 3 years ago

Agreed, sadly I think this issue is especially important despite the pain it will likely cause in the implementation.

BebeSparkelSparkel commented 3 years ago

Perhaps this isn't as hard you think. This could be implemented as:

data Flags
  :: Symbol -- prefix
  -> Symbol -- single letter flags
  -> *

then run would

Another option would be:

data Flags
  :: Symbol -- prefix
  -> [(Symbol,Symbol)] -- single letter map to flag
  -> *

this is a bit more flexible than the previous option that allows for mappings to flags that have more than one letter and allows for a different prefix for combined single letters flags than the other flags.

As for checking this it may be possible for a type function to ensure that there is a flag handler is defined after this.