Skip to content

Conversation

@ForbesLindesay
Copy link
Owner

No description provided.

@rollingversions
Copy link

rollingversions bot commented Oct 4, 2022

Change Log for parameter-reducers (2.0.0 → 2.1.0)

New Features

  • Add param.enumString utility to easily specify a parameter that can only have one of a list of defined values.

    Usage:

    import {startChain, param, parse} from 'parameter-reducers';
    
    const params = startChain().addParam(
      param.enumString(['-l', '--level'], 'level', [
        'info',
        'warn',
        'error',
      ] as const),
    );
    
    const {level = 'error'} = parse(params, process.argv.slice(2)).extract();
    
    if (level === 'info') {
      console.info('Some info');
    }
    if (level === 'info' || 'warn') {
      console.warn('Some warning');
    }
    console.warn('Some error');
  • Add param.positionalEnumString utility to easily specify a positional parameter that can only have one of a list of defined values.

    Usage:

    import {startChain, param, parse} from 'parameter-reducers';
    
    const params = startChain().addParam(
      param.positionalEnumString('env', ['staging', 'production'] as const),
    );
    
    const {env = 'staging'} = parse(params, process.argv.slice(2)).extract();
    
    if (env === 'staging') {
      console.info('Deploying to staging');
    }
    if (env === 'production') {
      console.warn('Deploying to production');
    }

Edit changelog

@ForbesLindesay ForbesLindesay merged commit ea4e2c3 into master Oct 4, 2022
@ForbesLindesay ForbesLindesay deleted the feat/fl/enum-string-parser branch October 4, 2022 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants