export function option()

in packages/just-task/src/option.ts [46:69]


export function option(key: string, options: OptionConfig = {}): void {
  const booleanArgs = ['array', 'boolean', 'count', 'normalize', 'string', 'number'] as const;
  const assignArgs = ['alias', 'coerce', 'default'] as const;

  for (const argName of booleanArgs) {
    if (options[argName]) {
      const argOpts = (argOptions[argName] ??= []) as string[];

      if (argOpts.indexOf(key) === -1) {
        argOpts.push(key);
      }
    }
  }

  for (const argName of assignArgs) {
    if (options[argName]) {
      (argOptions[argName] ??= {})[key] = options[argName];
    }
  }

  if (options.describe) {
    descriptions[key] = options.describe;
  }
}