Skip to content
This repository was archived by the owner on Aug 22, 2023. It is now read-only.
This repository was archived by the owner on Aug 22, 2023. It is now read-only.

parse does not execute with flags.build#default #46

Description

@lynchbomb

(Please direct this question to a different repo if warranted).

Current implementation:
https://github.com/TracerBench/tracerbench/blob/c9b4a5457cfcd21af93dc96f7cd1221eedf6b269/packages/cli/src/helpers/flags.ts#L7-L13

Use-case:
We have certain instances where we want to type check and parse flag values differently depending on if a default config.json value is being consumed vs explicitly flagged within the CLI command directly. ie

CLI: COMMAND --markers foo,buzz
CONFIG.json: "markers": ["foo", "buzz"]
parse: m => {
// return do something with m under both scenarios
}

Is it possible to "force" parse to execute within the context of flags.build when a default value is set. Appears currently if a default flag value is set parse is never executed.

flags.build#parse will execute

export const foo = flags.build({
  description: `foo foo`,
  parse: f => {
    if (typeof f === 'string') {
       // do something
    }
  }
});

flags.build#parse will NOT execute

export const foo = flags.build({
  default: 'foo',
  description: `foo foo`,
  parse: f => {
    if (typeof f === 'string') {
         // do something
    }
  }
});

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions