-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(cli): add @bomb.sh/tab completions #8639
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
Changes from 15 commits
e7b055b
ee0b7d1
65a7711
60438ab
55c98b4
64255a6
378b9e6
f48d105
2c17846
e73f720
fb31d39
d7277b7
7f0ccae
d9eeed4
39bab22
860f9e4
df49a27
8acfa84
0d969ce
b0c1db2
20ee067
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ import { normalize } from 'pathe' | |
| import c from 'tinyrainbow' | ||
| import { version } from '../../../package.json' with { type: 'json' } | ||
| import { benchCliOptionsConfig, cliOptionsConfig, collectCliOptionsConfig } from './cli-config' | ||
| import { setupTabCompletions } from './completions' | ||
|
|
||
| function addCommand(cli: CAC | Command, name: string, option: CLIOption<any>) { | ||
| const commandName = option.alias || name | ||
|
|
@@ -195,6 +196,7 @@ export function createCLI(options: CliParseOptions = {}): CAC { | |
| .command('[...filters]', undefined, options) | ||
| .action((filters, options) => start('test', filters, options)) | ||
|
|
||
| setupTabCompletions(cli) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isn't it async?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is, but that's intentional here. I wanted to keep |
||
| return cli | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| import type { CAC } from 'cac' | ||
| import tab from '@bomb.sh/tab/cac' | ||
|
|
||
| function testFilters(complete: (pattern: string, desc: string) => void) { | ||
| complete('**/*.test.ts', 'TypeScript test files') | ||
| complete('**/*.test.js', 'JavaScript test files') | ||
| complete('**/*.spec.ts', 'TypeScript spec files') | ||
| complete('**/*.spec.js', 'JavaScript spec files') | ||
| } | ||
|
|
||
| function benchFilters(complete: (pattern: string, desc: string) => void) { | ||
| complete('**/*.bench.ts', 'TypeScript benchmark files') | ||
| complete('**/*.bench.js', 'JavaScript benchmark files') | ||
| complete('**/*.benchmark.ts', 'TypeScript benchmark files') | ||
| complete('**/*.benchmark.js', 'JavaScript benchmark files') | ||
| } | ||
|
|
||
| function relatedFilters(complete: (pattern: string, desc: string) => void) { | ||
| complete('src/**/*.ts', 'TypeScript source files') | ||
| complete('src/**/*.js', 'JavaScript source files') | ||
| complete('lib/**/*.ts', 'TypeScript library files') | ||
| complete('lib/**/*.js', 'JavaScript library files') | ||
| } | ||
|
|
||
| export async function setupTabCompletions(cli: CAC): Promise<void> { | ||
|
AmirSa12 marked this conversation as resolved.
|
||
| await tab(cli, { | ||
| subCommands: { | ||
|
AmirSa12 marked this conversation as resolved.
Outdated
|
||
| run: { args: { filters: testFilters } }, | ||
| watch: { args: { filters: testFilters } }, | ||
| dev: { args: { filters: testFilters } }, | ||
| list: { args: { filters: testFilters } }, | ||
| related: { args: { filters: relatedFilters } }, | ||
| bench: { args: { filters: benchFilters } }, | ||
| init: { | ||
| args: { | ||
| project(complete) { | ||
| complete('browser', 'Initialize browser testing setup') | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| options: { | ||
| config(complete) { | ||
|
AmirSa12 marked this conversation as resolved.
Outdated
|
||
| complete('vitest.config.ts', 'TypeScript config file') | ||
| complete('vitest.config.js', 'JavaScript config file') | ||
| complete('vitest.config.mjs', 'ES module config file') | ||
| complete('vite.config.ts', 'Vite TypeScript config file') | ||
| complete('vite.config.js', 'Vite JavaScript config file') | ||
| }, | ||
| mode(complete) { | ||
|
AmirSa12 marked this conversation as resolved.
Outdated
|
||
| complete('test', 'Test mode') | ||
| complete('benchmark', 'Benchmark mode') | ||
| complete('development', 'Development mode') | ||
| complete('production', 'Production mode') | ||
| }, | ||
| environment(complete) { | ||
| complete('node', 'Node.js environment') | ||
| complete('jsdom', 'JSDOM environment') | ||
| complete('happy-dom', 'Happy DOM environment') | ||
| complete('edge-runtime', 'Edge runtime environment') | ||
| }, | ||
| pool(complete) { | ||
| complete('threads', 'Threads pool') | ||
| complete('forks', 'Forks pool') | ||
| complete('vmThreads', 'VM threads pool') | ||
| complete('vmForks', 'VM forks pool') | ||
| }, | ||
| reporter(complete) { | ||
| complete('default', 'Default reporter') | ||
| complete('verbose', 'Verbose reporter') | ||
| complete('dot', 'Dot reporter') | ||
| complete('json', 'JSON reporter') | ||
| complete('junit', 'JUnit reporter') | ||
| complete('html', 'HTML reporter') | ||
| complete('tap', 'TAP reporter') | ||
| complete('tap-flat', 'TAP flat reporter') | ||
| complete('hanging-process', 'Hanging process reporter') | ||
| }, | ||
| 'coverage.provider'(complete) { | ||
| complete('v8', 'V8 coverage provider') | ||
| complete('istanbul', 'Istanbul coverage provider') | ||
| complete('custom', 'Custom coverage provider') | ||
|
AmirSa12 marked this conversation as resolved.
Outdated
|
||
| }, | ||
| 'coverage.reporter'(complete) { | ||
| complete('text', 'Text coverage reporter') | ||
| complete('html', 'HTML coverage reporter') | ||
| complete('clover', 'Clover coverage reporter') | ||
| complete('json', 'JSON coverage reporter') | ||
| complete('json-summary', 'JSON summary coverage reporter') | ||
| complete('lcov', 'LCOV coverage reporter') | ||
| complete('lcovonly', 'LCOV only coverage reporter') | ||
| complete('teamcity', 'TeamCity coverage reporter') | ||
| complete('cobertura', 'Cobertura coverage reporter') | ||
| }, | ||
| 'browser.name'(complete) { | ||
| complete('chrome', 'Google Chrome') | ||
| complete('firefox', 'Mozilla Firefox') | ||
| complete('safari', 'Safari') | ||
| complete('edge', 'Microsoft Edge') | ||
| complete('chromium', 'Chromium') | ||
|
AmirSa12 marked this conversation as resolved.
Outdated
|
||
| }, | ||
| 'browser.provider'(complete) { | ||
|
AmirSa12 marked this conversation as resolved.
Outdated
|
||
| complete('playwright', 'Playwright provider') | ||
| complete('webdriverio', 'WebdriverIO provider') | ||
| complete('preview', 'Preview provider') | ||
| }, | ||
| testNamePattern(complete) { | ||
|
AmirSa12 marked this conversation as resolved.
Outdated
|
||
| complete('should.*work', 'Tests containing "should" and "work"') | ||
| complete('integration.*test', 'Integration tests') | ||
| complete('unit.*test', 'Unit tests') | ||
| }, | ||
| silent(complete) { | ||
| complete('true', 'Enable silent mode') | ||
| complete('false', 'Disable silent mode') | ||
| complete('passed-only', 'Show logs from failing tests only') | ||
| }, | ||
| }, | ||
| }) | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.