forked from OpenAtom-Linyaps/linyaps
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add bash completion for ll-builder
- Log:
- Loading branch information
Showing
3 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
usr/bin/ll-builder | ||
usr/share/linglong/builder/config.yaml | ||
usr/share/linglong/builder/templates/*.yaml | ||
usr/share/bash-completion/completions/ll-builder |
This file contains 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 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,36 @@ | ||
#!/bin/env bash | ||
|
||
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. | ||
# | ||
# SPDX-License-Identifier: LGPL-3.0-or-later | ||
|
||
# linglong builder completion | ||
|
||
__ll_builder_find_subcommand() | ||
{ | ||
for i in "${COMP_WORDS[@]}" | ||
do | ||
if ! [[ $i = -* ]] && ! [[ $i = ll-builder ]] | ||
then | ||
echo "$i" | ||
return | ||
fi | ||
done | ||
echo "" | ||
return | ||
} | ||
|
||
_ll_builder() | ||
{ | ||
local wordlist | ||
|
||
subcommand=$(__ll_builder_find_subcommand) | ||
wordlist=$(ll-builder "$subcommand" --help | grep -Po '((?<= )-\w|(?<= )--[\w-]+)|(?<=subcommand )\w+|^ + \w+$' | tr '\n' ' ') | ||
|
||
local cur=${COMP_WORDS[COMP_CWORD]}; | ||
COMPREPLY=( $(compgen -W "${wordlist}" -- "${cur}") ) | ||
|
||
return 0 | ||
} | ||
|
||
complete -F _ll_builder ll-builder |