cacjs / cac

Simple yet powerful framework for building command-line apps.
MIT License
2.65k stars 104 forks source link

feat: allow non-array types #106

Open privatenumber opened 3 years ago

privatenumber commented 3 years ago

Issue Type

Expected

I'd like to be able to just specify a type (eg. String), without making it an array String (eg. [String])

I'd like to be able to do:

const cli = cac('cli')
    .option('--size <size>', 'Size', {
        type: String,
    })

and get the parsed options:

{ '--': [], size: '16' }

Actual

Instead, I currently must do

const cli = cac('cli')
    .option('--size <size>', 'Size', {
        type: [String],
    })

and get the parsed options:

{ '--': [], size: ['16'] }

as communicated by the type: https://github.com/cacjs/cac/blob/f51fc2254d7ea30b4faea76f69f52fe291811e4f/src/Option.ts#L5

Possible Solutions

Info

egoist commented 3 years ago

Ah yes, I actually forgot why it was designed to be an array by default 😅

Codpoe commented 3 years ago

It also confuses me...🤔