-
Notifications
You must be signed in to change notification settings - Fork 137
feat(completion): implement dynamic shell completion with vp run task support
#1181
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
+297
−139
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
474634a
feat(completion): switch to dynamic shell completion
nekomoyi 607d912
feat(delegate): add output handling for local cli execution
nekomoyi 80a707e
feat(completion): implement dynamic task completion for vp run
nekomoyi b64280f
chore(completion): update shell completion variable to VP_COMPLETE
nekomoyi e00859b
feat(completion): support hashtags and quotes in task completion
nekomoyi 96e9491
lint
nekomoyi b8a3d62
fix(completion): update PowerShell completion variable to VP_COMPLETE
nekomoyi f45c026
feat(cli): validate vite-plus installation before task completions
nekomoyi 3ec4723
fix(completion): replace bash completion script to handle colons in t…
nekomoyi aa10bc5
chore(js_executor): restore code structure and comments
nekomoyi ac7a667
Merge branch 'main' into feat/dynamic-completion
nekomoyi f203c62
fix(test): update PowerShell completion assertion to check for VP_COM…
nekomoyi 6109711
Merge branch 'main' into feat/dynamic-completion
nekomoyi f78eaab
Merge branch 'main' into feat/dynamic-completion
nekomoyi 01bcb18
feat(env): add cleanup for legacy completion directory
nekomoyi 62b6e8d
fix(cli): use has_vite_plus_dependency for dependency check
nekomoyi 9ae77d1
Merge branch 'main' into feat/dynamic-completion
fengmk2 ef5a63b
Merge branch 'main' into feat/dynamic-completion
fengmk2 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,64 @@ | ||
| _clap_reassemble_words() { | ||
| if [[ "$COMP_WORDBREAKS" != *:* ]]; then | ||
| return | ||
| fi | ||
| local i j=0 line=$COMP_LINE | ||
| words=() | ||
| _CLAP_COMPLETE_INDEX=0 | ||
| for ((i = 0; i < ${#COMP_WORDS[@]}; i++)); do | ||
| if ((i > 0 && j > 0)) && [[ "${COMP_WORDS[i]}" == :* || "${words[j-1]}" == *: ]] && [[ "$line" != [[:blank:]]* ]]; then | ||
| words[j-1]="${words[j-1]}${COMP_WORDS[i]}" | ||
| else | ||
| words[j]="${COMP_WORDS[i]}" | ||
| ((j++)) | ||
| fi | ||
| if ((i == COMP_CWORD)); then | ||
| _CLAP_COMPLETE_INDEX=$((j - 1)) | ||
| fi | ||
| line=${line#*"${COMP_WORDS[i]}"} | ||
| done | ||
| } | ||
|
|
||
| _clap_trim_completions() { | ||
| local cur="${words[_CLAP_COMPLETE_INDEX]}" | ||
| if [[ "$cur" != *:* || "$COMP_WORDBREAKS" != *:* ]]; then | ||
| return | ||
| fi | ||
| local colon_word=${cur%"${cur##*:}"} | ||
| local i=${#COMPREPLY[*]} | ||
| while [[ $((--i)) -ge 0 ]]; do | ||
| COMPREPLY[$i]=${COMPREPLY[$i]#"$colon_word"} | ||
| done | ||
| } | ||
|
|
||
| _clap_complete_vp() { | ||
| local IFS=$'\013' | ||
| local _CLAP_COMPLETE_INDEX=${COMP_CWORD} | ||
| local _CLAP_COMPLETE_COMP_TYPE=${COMP_TYPE} | ||
| if compopt +o nospace 2> /dev/null; then | ||
| local _CLAP_COMPLETE_SPACE=false | ||
| else | ||
| local _CLAP_COMPLETE_SPACE=true | ||
| fi | ||
| local words=("${COMP_WORDS[@]}") | ||
| _clap_reassemble_words | ||
| COMPREPLY=( $( \ | ||
| _CLAP_IFS="$IFS" \ | ||
| _CLAP_COMPLETE_INDEX="$_CLAP_COMPLETE_INDEX" \ | ||
| _CLAP_COMPLETE_COMP_TYPE="$_CLAP_COMPLETE_COMP_TYPE" \ | ||
| _CLAP_COMPLETE_SPACE="$_CLAP_COMPLETE_SPACE" \ | ||
| VP_COMPLETE="bash" \ | ||
| "vp" -- "${words[@]}" \ | ||
| ) ) | ||
| if [[ $? != 0 ]]; then | ||
| unset COMPREPLY | ||
| elif [[ $_CLAP_COMPLETE_SPACE == false ]] && [[ "${COMPREPLY-}" =~ [=/:]$ ]]; then | ||
| compopt -o nospace | ||
| fi | ||
| _clap_trim_completions | ||
| } | ||
| if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then | ||
| complete -o nospace -o bashdefault -o nosort -F _clap_complete_vp vp | ||
| else | ||
| complete -o nospace -o bashdefault -F _clap_complete_vp vp | ||
| fi |
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
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.