Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flag/Argument Transformations #7

Open
coreybutler opened this issue Oct 21, 2020 · 0 comments
Open

Flag/Argument Transformations #7

coreybutler opened this issue Oct 21, 2020 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@coreybutler
Copy link
Member

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.

@coreybutler coreybutler added the enhancement New feature or request label Oct 21, 2020
@coreybutler coreybutler self-assigned this Oct 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant