Skip to content

Boolean option and variadic arguments #187

@beci

Description

@beci

As descibed in Option synopsis:
-f, --file <file> means the option can be provided either by its short notation -f or by its long notation --file. You don't have to repeat the placeholder twice in that case.

But the highlighted part is bad, because it's not possible to create an option without a placeholder. The one which is bother me is the default -v, --verbose, which leads to the following bug:

#!/usr/bin/env ts-node
import { program } from "@caporal/core"

program
  .version("1.0.0")
  .description("Bad parse")
  .command("test", "Test bad parsing")
  .argument("[dates...]", "variadic arg ")
  .action(({ logger, args, options }) => {
    logger.debug("log debug")
    logger.info("args", args)
    logger.info("args", options)
    
  })

program.run()
node -r ts-node/register src/bad.ts test -v first second
debug: log debug
info: args
info: { dates: [ 'second' ] }
info: args
info: { v: 'first' }

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions