Add bash-completion for the buildscript.

Submitted by Robert Langhammer on Oct. 12, 2019, 9:45 p.m.

Details

Message ID 20191012214536.22903-1-rlanghammer@web.de
State Superseded
Headers show

Commit Message

Robert Langhammer Oct. 12, 2019, 9:45 p.m.
Signed-off-by: Robert Langhammer <rlanghammer@web.de>
---
 bash-completion.sh | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 bash-completion.sh

--
2.20.1

Patch hide | download patch | download mbox

diff --git a/bash-completion.sh b/bash-completion.sh
new file mode 100644
index 0000000..d1e20f6
--- /dev/null
+++ b/bash-completion.sh
@@ -0,0 +1,40 @@ 
+# completion for buildscript
+# just source this script
+# or put it in your /etc/bash_completion.d/ (you should rename it)
+
+_buildscript() {
+case "${COMP_WORDS[1]}" in
+config)
+	COMPREPLY=($(compgen -W "openwrt" "${COMP_WORDS[2]}"))
+	;;
+selectbsp)
+	COMPREPLY=($(compgen -W "$(find bsp -name '*.bsp')" "${COMP_WORDS[2]}"))
+	;;
+selectvariant)
+	COMPREPLY=($(compgen -W "$("${COMP_WORDS[0]}" "${COMP_WORDS[1]}" | sed '0,/available variants:/d')" "${COMP_WORDS[2]}"))
+	;;
+build)
+	COMPREPLY=($(compgen -W "fast debug" "${COMP_WORDS[2]}"))
+	;;
+buildall)
+	COMPREPLY=($(compgen -W "fast" "${COMP_WORDS[2]}"))
+	;;
+release)
+	case "${COMP_WORDS[2]}" in
+	all)
+		COMPREPLY=($(compgen -W "fast" "${COMP_WORDS[3]}"))
+		;;
+	fast)
+		COMPREPLY=($(compgen -W "all" "${COMP_WORDS[3]}"))
+		;;
+	*)
+		COMPREPLY=($(compgen -W "fast all" "${COMP_WORDS[2]}"))
+		;;
+	esac;;
+*)
+	COMPREPLY=($(compgen -W "selectbsp selectvariant prepare config build buildall release clean" "${COMP_WORDS[1]}"))
+	;;
+esac
+}
+
+complete -F _buildscript ./buildscript

Comments

Fabian Blaese Nov. 10, 2019, 1:15 p.m.
Super Sache!

Zwei Vorschläge:
- buildscript.completion (o.ä.) als Dateiname? Vielleicht bietet sich ein eigenes Unterverzeichnis "tools" an.
- Keine execute permission

Beim applien darauf achten, ob das buildscript dann schon "updatefeeds" (siehe Adrians Patch) enthält, ggf. ergänzen.

Gruß
Fabian

On 12.10.19 23:45, Robert Langhammer wrote:
> Signed-off-by: Robert Langhammer <rlanghammer@web.de>
> ---
>  bash-completion.sh | 40 ++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 40 insertions(+)
>  create mode 100644 bash-completion.sh
> 
> diff --git a/bash-completion.sh b/bash-completion.sh
> new file mode 100644
> index 0000000..d1e20f6
> --- /dev/null
> +++ b/bash-completion.sh
> @@ -0,0 +1,40 @@
> +# completion for buildscript
> +# just source this script
> +# or put it in your /etc/bash_completion.d/ (you should rename it)
> +
> +_buildscript() {
> +case "${COMP_WORDS[1]}" in
> +config)
> +	COMPREPLY=($(compgen -W "openwrt" "${COMP_WORDS[2]}"))
> +	;;
> +selectbsp)
> +	COMPREPLY=($(compgen -W "$(find bsp -name '*.bsp')" "${COMP_WORDS[2]}"))
> +	;;
> +selectvariant)
> +	COMPREPLY=($(compgen -W "$("${COMP_WORDS[0]}" "${COMP_WORDS[1]}" | sed '0,/available variants:/d')" "${COMP_WORDS[2]}"))
> +	;;
> +build)
> +	COMPREPLY=($(compgen -W "fast debug" "${COMP_WORDS[2]}"))
> +	;;
> +buildall)
> +	COMPREPLY=($(compgen -W "fast" "${COMP_WORDS[2]}"))
> +	;;
> +release)
> +	case "${COMP_WORDS[2]}" in
> +	all)
> +		COMPREPLY=($(compgen -W "fast" "${COMP_WORDS[3]}"))
> +		;;
> +	fast)
> +		COMPREPLY=($(compgen -W "all" "${COMP_WORDS[3]}"))
> +		;;
> +	*)
> +		COMPREPLY=($(compgen -W "fast all" "${COMP_WORDS[2]}"))
> +		;;
> +	esac;;
> +*)
> +	COMPREPLY=($(compgen -W "selectbsp selectvariant prepare config build buildall release clean" "${COMP_WORDS[1]}"))
> +	;;
> +esac
> +}
> +
> +complete -F _buildscript ./buildscript
> --
> 2.20.1
>
Robert Langhammer Nov. 30, 2019, 10:10 p.m.
Hi Fabian,

einen eigenen Ordner find ich auch gut. Vielleicht hat ja noch jemand
nette Tools die man da rein werfen kann. Dann wäre auch eine README da
drin nicht schlecht.

Patch kommt.

Gruß Robert

Am 10.11.19 um 14:15 schrieb Fabian Bläse:
> Super Sache!
>
> Zwei Vorschläge:
> - buildscript.completion (o.ä.) als Dateiname? Vielleicht bietet sich ein eigenes Unterverzeichnis "tools" an.
> - Keine execute permission
>
> Beim applien darauf achten, ob das buildscript dann schon "updatefeeds" (siehe Adrians Patch) enthält, ggf. ergänzen.
>
> Gruß
> Fabian
>
> On 12.10.19 23:45, Robert Langhammer wrote:
>> Signed-off-by: Robert Langhammer <rlanghammer@web.de>
>> ---
>>  bash-completion.sh | 40 ++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 40 insertions(+)
>>  create mode 100644 bash-completion.sh
>>
>> diff --git a/bash-completion.sh b/bash-completion.sh
>> new file mode 100644
>> index 0000000..d1e20f6
>> --- /dev/null
>> +++ b/bash-completion.sh
>> @@ -0,0 +1,40 @@
>> +# completion for buildscript
>> +# just source this script
>> +# or put it in your /etc/bash_completion.d/ (you should rename it)
>> +
>> +_buildscript() {
>> +case "${COMP_WORDS[1]}" in
>> +config)
>> +	COMPREPLY=($(compgen -W "openwrt" "${COMP_WORDS[2]}"))
>> +	;;
>> +selectbsp)
>> +	COMPREPLY=($(compgen -W "$(find bsp -name '*.bsp')" "${COMP_WORDS[2]}"))
>> +	;;
>> +selectvariant)
>> +	COMPREPLY=($(compgen -W "$("${COMP_WORDS[0]}" "${COMP_WORDS[1]}" | sed '0,/available variants:/d')" "${COMP_WORDS[2]}"))
>> +	;;
>> +build)
>> +	COMPREPLY=($(compgen -W "fast debug" "${COMP_WORDS[2]}"))
>> +	;;
>> +buildall)
>> +	COMPREPLY=($(compgen -W "fast" "${COMP_WORDS[2]}"))
>> +	;;
>> +release)
>> +	case "${COMP_WORDS[2]}" in
>> +	all)
>> +		COMPREPLY=($(compgen -W "fast" "${COMP_WORDS[3]}"))
>> +		;;
>> +	fast)
>> +		COMPREPLY=($(compgen -W "all" "${COMP_WORDS[3]}"))
>> +		;;
>> +	*)
>> +		COMPREPLY=($(compgen -W "fast all" "${COMP_WORDS[2]}"))
>> +		;;
>> +	esac;;
>> +*)
>> +	COMPREPLY=($(compgen -W "selectbsp selectvariant prepare config build buildall release clean" "${COMP_WORDS[1]}"))
>> +	;;
>> +esac
>> +}
>> +
>> +complete -F _buildscript ./buildscript
>> --
>> 2.20.1
>>
Fabian Blaese Dec. 3, 2019, 2:47 p.m.
Reviewed-by: Fabian Bläse <fabian@blaese.de>