vilicvane / clime

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

[Bug] Wrong parsing not required params #56

Closed whalemare closed 4 years ago

whalemare commented 4 years ago

When I have 2 not-required params in my command, parsed only first one.

Steps to reproduce:

  1. Write command that have 2 not required params
    @command()
    export default class extends Command {
    execute(@param({required: false}) first: boolean, @param({required: false}) second: boolean) {
    console.log('first =', first)
    console.log('second =', second)
    }
    }
  2. Execute it and pass only second ts-node ./src/index.ts second

Expected

first = undefined
second = true

But have

first = true
second = undefined

Sample: https://github.com/lamantin-group/publish/blob/bug/clime/src/commands/default.ts#L20

whalemare commented 4 years ago

@vilic Some comments maybe? What I do wrong?

vilicvane commented 4 years ago

@whalemare I think the behavior is expected. You might want to use options instead of params in this case.

https://github.com/vilic/clime#parameter-types-and-options-schema

Thus use command --first or command --second or command --first --second

Another option is to use @params() platforms in the same example and do something like: platforms.includes('ios') or platforms.includes('android')

whalemare commented 4 years ago

Ok, thank you!