-
Notifications
You must be signed in to change notification settings - Fork 100
feat(cli): add tab completions #1082
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
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
3ce4f79
feat(cli): add tab completions
AmirSa12 447e1a3
readme
AmirSa12 0461d5c
[autofix.ci] apply automated fixes
autofix-ci[bot] 394e3bc
update
AmirSa12 2bf2b6c
bombshell v0.0.5
AmirSa12 22fc13c
types
AmirSa12 8877baa
update
AmirSa12 81e36cf
updates
AmirSa12 d1babb4
use node module resolution
AmirSa12 632781d
Merge remote-tracking branch 'origin/main' into feat/tab-completions
danielroe 2252472
refactor: use native node to run completions data
danielroe 87e58f9
chore: update tab to version 0.0.7
AmirSa12 1860f10
chore: readme
AmirSa12 63b2c8b
Merge remote-tracking branch 'origin/main' into feat/tab-completions
danielroe d4213cd
chore: move into build script
danielroe d64d259
chore: suppress lint
danielroe c7352b5
chore: lint
danielroe 4e7d9bc
build: also for create nuxt
danielroe 6325654
build: move back to postinstall
danielroe f15c787
docs: remove global installation instructions
danielroe 1ede8e8
chore: knip update
danielroe c1c28d0
chore: use file url for output path
danielroe 243bf65
chore: update tab to version 0.0.8
AmirSa12 c016105
update tab to version 0.0.9
AmirSa12 590290c
Merge remote-tracking branch 'upstream/main' into feat/tab-completions
AmirSa12 d37a720
Merge remote-tracking branch 'upstream/main' into feat/tab-completions
AmirSa12 166246a
Merge remote-tracking branch 'origin/main' into feat/tab-completions
danielroe c9c8bf7
build: use module url for import
danielroe 44a49d1
chore: dance, dance little man
danielroe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,3 +10,4 @@ stats.json | |
| playground-bun* | ||
| playground-deno* | ||
| playground-node* | ||
| packages/nuxi/src/utils/completions-data.ts | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import type { ArgsDef, CommandDef } from 'citty' | ||
| import tab from '@bomb.sh/tab/citty' | ||
| import { templates } from './utils/completions-data' | ||
|
|
||
| export async function setupInitCompletions<T extends ArgsDef = ArgsDef>(command: CommandDef<T>) { | ||
| const completion = await tab(command) | ||
|
|
||
| const templateOption = completion.options?.get('template') | ||
| if (templateOption) { | ||
| templateOption.handler = (complete) => { | ||
| for (const template of templates) { | ||
| complete(template, '') | ||
| } | ||
| } | ||
| } | ||
|
|
||
| const logLevelOption = completion.options?.get('logLevel') | ||
| if (logLevelOption) { | ||
| logLevelOption.handler = (complete) => { | ||
| complete('silent', 'No logs') | ||
| complete('info', 'Standard logging') | ||
| complete('verbose', 'Detailed logging') | ||
| } | ||
| } | ||
|
|
||
| return completion | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import type { ArgsDef, CommandDef } from 'citty' | ||
| import tab from '@bomb.sh/tab/citty' | ||
| import { nitroPresets, templates } from './utils/completions-data' | ||
|
|
||
| export async function initCompletions<T extends ArgsDef = ArgsDef>(command: CommandDef<T>) { | ||
| const completion = await tab(command) | ||
|
|
||
| const devCommand = completion.commands.get('dev') | ||
| if (devCommand) { | ||
| const portOption = devCommand.options.get('port') | ||
| if (portOption) { | ||
| portOption.handler = (complete) => { | ||
| complete('3000', 'Default development port') | ||
| complete('3001', 'Alternative port') | ||
| complete('8080', 'Common alternative port') | ||
| } | ||
| } | ||
|
|
||
| const hostOption = devCommand.options.get('host') | ||
| if (hostOption) { | ||
| hostOption.handler = (complete) => { | ||
| complete('localhost', 'Local development') | ||
| complete('0.0.0.0', 'Listen on all interfaces') | ||
| complete('127.0.0.1', 'Loopback address') | ||
| } | ||
| } | ||
| } | ||
|
|
||
| const buildCommand = completion.commands.get('build') | ||
| if (buildCommand) { | ||
| const presetOption = buildCommand.options.get('preset') | ||
| if (presetOption) { | ||
| presetOption.handler = (complete) => { | ||
| for (const preset of nitroPresets) { | ||
| complete(preset, '') | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| const initCommand = completion.commands.get('init') | ||
| if (initCommand) { | ||
| const templateOption = initCommand.options.get('template') | ||
| if (templateOption) { | ||
| templateOption.handler = (complete) => { | ||
| for (const template of templates) { | ||
| complete(template, '') | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| const addCommand = completion.commands.get('add') | ||
| if (addCommand) { | ||
| const cwdOption = addCommand.options.get('cwd') | ||
| if (cwdOption) { | ||
| cwdOption.handler = (complete) => { | ||
| complete('.', 'Current directory') | ||
| } | ||
| } | ||
| } | ||
|
|
||
| const logLevelCommands = ['dev', 'build', 'generate', 'preview', 'prepare', 'init'] | ||
| for (const cmdName of logLevelCommands) { | ||
| const cmd = completion.commands.get(cmdName) | ||
| if (cmd) { | ||
| const logLevelOption = cmd.options.get('logLevel') | ||
| if (logLevelOption) { | ||
| logLevelOption.handler = (complete) => { | ||
| complete('silent', 'No logs') | ||
| complete('info', 'Standard logging') | ||
| complete('verbose', 'Detailed logging') | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return completion | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.