How to use the @oclif/command.flags.enum function in @oclif/command

To help you get started, we’ve selected a few @oclif/command examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github elmsln / WCFactory / packages / cli / src / commands / start.js View on Github external
async run() {
    const { args, flags } = this.parse(Start)
    // prompt user for remaining flags
    Object.assign(flags, await promptUser(questions, flags, this))
    // call the generator
    env.run('wcfactory:start', flags)
  }
}

Start.description = 'Create a company for your factories.'

Start.flags = {
  help: flags.help({ char: 'h' }),
  author: flags.string({ char: 'a', description: 'Author name for your elements' }),
  copyrightOwner: flags.string({ char: 'c', description: 'Copyright owner of your work' }),
  license: flags.enum({
    char: 'l',
    description: 'Software License to use',
    options: ["Apache-2.0", "MIT", "BSD-3-Clause", "BSD-2-Clause"]
  })
}

module.exports = Start
github feinoujc / gh-search-cli / src / commands / issues.ts View on Github external
description:
					'Filters items missing certain metadata, such as label, milestone, or assignee',
			}),
			SHA: flags.string({
				description:
					'If you know the specific SHA hash of a commit, you can use it to search for pull requests that contain that SHA. The SHA syntax must be at least seven characters.',
			}),
			interactions: flags.string({
				description:
					'You can filter issues and pull requests by the number of interactions with the interactions qualifier along with greater than, less than, and range qualifiers. The interactions count is the number of reactions and comments on an issue or pull request.',
			}),
			reactions: flags.string({
				description:
					'You can filter issues and pull requests by the number of reactions using the reactions qualifier along with greater than, less than, and range qualifiers.',
			}),
			review: flags.enum({
				options: ['none', 'required', 'approved', 'changes_requested'],
				description:
					'You can filter pull requests based on their review status',
			}),
			'reviewed-by': flags.string({
				description: 'Filter pull requests by reviewer.',
			}),
			'review-requested': flags.string({
				description: 'Filter pull requests by requested reviewer.',
			}),
			'team-review-requested': flags.string({
				description: 'Filter pull requests by requested reviewer.',
			}),
			language: flags.string({
				char: 'l',
				description:
github feinoujc / gh-search-cli / src / commands / repositories.ts View on Github external
"Search repositories based on whether or not they're a mirror and are hosted elsewhere.",
			}),
			archived: flags.boolean({
				allowNo: true,
				description:
					'Filters whether archived repositories should be included (--archived) or not (--no-archived).',
			}),
			'good-first-issues': flags.string({
				description:
					'Search for repositories that have a minimum number of issues labeled help-wanted.',
			}),
			'help-wanted-issues': flags.string({
				description:
					'Search for repositories that have a minimum number of issues labeled good-first-issue.',
			}),
			sort: flags.enum({
				char: 's',
				description:
					'The sort field. Default: results are sorted by best match.',
				options: ['stars', 'forks', 'updated'],
			}),
		},
		['sort'],
	);

	static aliases = ['repo', 'repository'];

	static args = [...Command.args];

	format(data: ApiResponse): TableResult {
		const rows = data.items.reduce((acc, item) => {
			const repo = chalk.cyan(item.full_name);
github anttiviljami / openapicmd / src / common / flags.ts View on Github external
export const outputFormat = () => ({
  format: flags.enum({
    char: 'f',
    description: '[default: yaml] output format',
    options: ['json', 'yaml', 'yml'],
    exclusive: ['json', 'yaml'],
  }),
  json: flags.boolean({ description: 'format as json (short for -f json)', exclusive: ['format', 'yaml'] }),
  yaml: flags.boolean({ description: 'format as yaml (short for -f yaml)', exclusive: ['format', 'json'] }),
});
github twilio / twilio-cli / src / base-commands / base-command.js View on Github external
}
    }
    const processOutput = OutputFormats[this.flags['output-format']];
    process.stdout.write(processOutput(dataArray, limitedData || dataArray) + '\n');
  }
}

BaseCommand.flags = {
  'log-level': flags.enum({
    char: 'l',
    default: 'info',
    options: Object.keys(LoggingLevel),
    description: 'Level of logging messages'
  }),

  'output-format': flags.enum({
    char: 'o',
    default: 'columns',
    options: Object.keys(OutputFormats),
    description: 'Format of command output'
  })
};

module.exports = BaseCommand;
github feinoujc / gh-search-cli / src / commands / issues.ts View on Github external
}

const jiraRegex = /^(\[?[A-Z]{2,10}-\d{1,5}\]?[\s|:]*)?(.*)$/im;

export default class Issues extends Command {
	static description =
		'search github issues. https://developer.github.com/v3/search/#search-issues';

	static examples = [
		`$ ghs issues --is open --involves my-github-username
`,
	];

	static flags = buildFlags(
		{
			type: flags.enum({
				char: 't',
				description:
					'With this qualifier you can restrict the search to issues (issue) or pull request (pr) only.',
				options: ['issue', 'pr'],
			}),
			in: flags.string({
				description:
					'Qualifies which fields are searched. With this qualifier you can restrict the searchto just the title (title), body (body), comments (comments), or any combination of these.',
			}),
			author: flags.string({
				description:
					'Finds issues or pull requests created by a certain user. Use --current-author to use the currently configured git username.',
			}),
			'current-author': flags.boolean({
				hidden: true,
			}),
github feinoujc / gh-search-cli / src / commands / issues.ts View on Github external
}),
			'current-commenter': flags.boolean({
				hidden: true,
			}),
			involves: flags.string({
				description:
					'Finds issues or pull requests that were either created by a certain user, assigned to that user, mention that user, or were commented on by that user. Use --current-involves to use the currently configured git username.',
			}),
			'current-involves': flags.boolean({
				hidden: true,
			}),
			team: flags.string({
				description:
					"For organizations you're a member of, finds issues or pull requests that @mention a team within the organization.",
			}),
			state: flags.enum({
				description:
					"Filter issues or pull requests based on whether they're open or closed.",
				options: ['open', 'closed'],
			}),
			label: flags.string({
				description: 'Filters issues or pull requests based on their labels.',
			}),
			milestone: flags.string({
				description:
					'Finds issues or pull requests that are a part of a milestone within a repository.',
			}),
			no: flags.string({
				description:
					'Filters items missing certain metadata, such as label, milestone, or assignee',
			}),
			SHA: flags.string({
github feinoujc / gh-search-cli / src / commands / code.ts View on Github external
'current-user': flags.boolean({
				hidden: true,
			}),
			repo: flags.string({
				char: 'r',
				description: 'Limits searches to a specific repository.',
			}),
			org: flags.string({
				char: 'o',
				description: 'Limits searchs to a specific organization',
			}),
			text: flags.boolean({
				char: 't',
				description: 'Show full text match',
			}),
			sort: flags.enum({
				char: 's',
				options: ['indexed'],
				description:
					'The sort field. Can only be indexed, which indicates how recently a file has been indexed by the GitHub search infrastructure. Default: results are sorted by best match.',
			}),
		},
		['sort', 'text'],
	);

	static args = [...Command.args];

	format(data: ApiResponse, opts: FormatOptions): TableResult {
		const rows = data.items.reduce((acc, item) => {
			const repo = chalk.cyan(item.repository.name);
			const fullPath: string = item.html_url;
github feinoujc / gh-search-cli / src / commands / commits.ts View on Github external
}),
			merge: flags.boolean({
				allowNo: true,
				description:
					'--merge filters to merge commits, --no-merge filters out merge commits.',
			}),
			hash: flags.string({
				description: 'Matches commits by hash.',
			}),
			tree: flags.string({
				description: 'Matches commits with the specified git tree hash.',
			}),
			parent: flags.string({
				description: 'Matches commits that have a particular parent.',
			}),
			is: flags.enum({
				options: ['public', 'private'],
				description: 'Matches public or private repositories.',
			}),
			user: flags.string({
				description:
					'Limits searches to a specific user. Use --current-user to use the currently configured git username.',
			}),
			'current-user': flags.boolean({
				hidden: true,
			}),
			org: flags.string({
				description: 'Limits searches to a specific organization.',
			}),
			repo: flags.string({
				description: 'Limits searches to a specific repository.',
			}),
github rucken / cli / src / commands / prepare.ts View on Github external
import { Command, flags } from '@oclif/command';
import { readFileSync } from 'fs';
import { resolve as resolvePath } from 'path';
import { Config } from './config';
import { MakeTsList } from './make-ts-list';
import { Translate } from './translate';
import { VersionUpdater } from './version-updater';

export class Prepare extends Command {
  static description = 'translate + make-ts-list + version-update + config';

  static flags = {
    help: flags.help({ char: 'h' }),
    mode: flags.enum({ char: 'm', options: ['dev', 'prod'] })
  };
  static args = [{ name: 'folder' }];

  async run() {
    process.setMaxListeners(0);
    require('events').EventEmitter.defaultMaxListeners = 100;
    require('events').EventEmitter.defaultMaxListeners = 100;
    const { args, flags } = this.parse(Prepare);
    const folder = args.folder ? resolvePath(args.folder) : resolvePath('.');
    const mode = flags.mode;
    const angularConfigPath = resolvePath(folder, 'angular.json');

    let angularConfig: any;
    try {
      const content = readFileSync(angularConfigPath).toString();
      angularConfig = JSON.parse(content);