Function createOptionsGetter

  • Converts command options to a getter object.

    This function transforms an Options object into a CommandOptionsGetter object that has getter methods for each of the options. The getters can then be used to retrieve the values of the options dynamically. If an option has defined aliases, the returned getter will have additional getter methods for each alias, all pointing to the original option's value.

    Additionally, the returned object has a get method, which accepts an array of option keys and returns an object with the corresponding camelCased key-value pairs.

    Type Parameters

    Parameters

    Returns OptionsGetter<TOptionsConfig>

    const optionsConfig = {
    f: {
    type: 'string',
    alias: ['foo'],
    default: 'default foo'
    },
    };
    const optionsGetter = createOptionsGetter({ optionsConfig });
    const val = await optionsGetter.foo(); // 'default foo'