Skip to content

Flag/Argument TransformationsΒ #7

@coreybutler

Description

@coreybutler

I want a transformer to process arguments/flags passed to the CLI utility. For example:

my cmd -i ./local/path
flags: {
  input: {
    alias: 'i',
    description: 'The input source directory.',
    type: 'string',
    transform (value) {
      return path.resolve(value)
    }
  }
}

In the case above, the resulting "input" flag would have a value of /users/cbutler/local/path instead of ./local/path because the transformer modifies the data before it is used within a command.

This could be used for sanitizing inputs of any kind, or normalizing data (such as case sensitivity, typos, etc). It would be better to do this where the flag is defined, instead of requiring each and every command handler to do this. Currently, middleware is the only way to handle this, but that's less intuitive than a transformer.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions