diff options
author | Adam Malinowski <a.malinowsk2@partner.samsung.com> | 2016-02-26 08:39:35 +0100 |
---|---|---|
committer | Adam Malinowski <a.malinowsk2@partner.samsung.com> | 2016-05-05 13:01:17 +0200 |
commit | 992f65d2ad0fe4219f1d41f9d0bc04dfafd729f1 (patch) | |
tree | 8a79b8d322e90e33170b1816a53d281c825d413c | |
parent | 5351deab2dbced9aa2d426a413f157125a33de7c (diff) | |
download | sd-mux-992f65d2ad0fe4219f1d41f9d0bc04dfafd729f1.tar.gz sd-mux-992f65d2ad0fe4219f1d41f9d0bc04dfafd729f1.tar.bz2 sd-mux-992f65d2ad0fe4219f1d41f9d0bc04dfafd729f1.zip |
Add bash completion script
Change-Id: I281d9c9a72ba8b764de855fd5ebb38d6b4399ca1
-rw-r--r-- | debian/bash-completion | 1 | ||||
-rw-r--r-- | debian/control | 1 | ||||
-rwxr-xr-x | debian/rules | 2 | ||||
-rw-r--r-- | etc/bash_completion.d/sd-mux-ctrl | 45 | ||||
-rw-r--r-- | packaging/sd-mux-ctrl.spec | 4 |
5 files changed, 52 insertions, 1 deletions
diff --git a/debian/bash-completion b/debian/bash-completion new file mode 100644 index 0000000..441000e --- /dev/null +++ b/debian/bash-completion @@ -0,0 +1 @@ +etc/bash_completion.d/sd-mux-ctrl diff --git a/debian/control b/debian/control index d6d09b1..f69f762 100644 --- a/debian/control +++ b/debian/control @@ -5,6 +5,7 @@ Priority: optional Build-Depends: libftdi1-dev (>= 1.2), libpopt-dev, debhelper (>=9), + bash-completion, Standards-Version: 3.9.5 Package: sd-mux-ctrl diff --git a/debian/rules b/debian/rules index 2d33f6a..18c1c50 100755 --- a/debian/rules +++ b/debian/rules @@ -1,4 +1,4 @@ #!/usr/bin/make -f %: - dh $@ + dh $@ --with bash-completion diff --git a/etc/bash_completion.d/sd-mux-ctrl b/etc/bash_completion.d/sd-mux-ctrl new file mode 100644 index 0000000..6cfa28a --- /dev/null +++ b/etc/bash_completion.d/sd-mux-ctrl @@ -0,0 +1,45 @@ +# Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# @file etc/bash_completion.d/sd-mux-ctrl +# @author Adam Malinowski <a.malinowsk2@partner.samsung.com> +# + +_sdmux() +{ + local cur prev opts + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + opts="--help --usage --list --device-serial --device-id --show-serial --set-serial --info --status --init --tick --tick-time --dut --ts --vendor --pins --invert" + + case "${prev}" in + --device-serial) + local running=$(sd-mux-ctrl -l | awk '/Serial/ {sub(",$", "", $6); print $6}') + COMPREPLY=( $(compgen -W "${running}" -- ${cur}) ) + return 0 + ;; + --device-id) + local running=$(sd-mux-ctrl -l | awk '/Serial/ {sub(",$", "", $2); print $2}') + COMPREPLY=( $(compgen -W "${running}" -- ${cur}) ) + return 0 + ;; + *) + ;; + esac + + COMPREPLY=($(compgen -W "${opts}" -- ${cur})) + return 0 +} +complete -F _sdmux sd-mux-ctrl diff --git a/packaging/sd-mux-ctrl.spec b/packaging/sd-mux-ctrl.spec index a949add..66450a5 100644 --- a/packaging/sd-mux-ctrl.spec +++ b/packaging/sd-mux-ctrl.spec @@ -15,6 +15,7 @@ Source0: %{name}_%{version}.tar.gz BuildRequires: cmake Requires: libftdi >= 1.2 Requires: popt +Requires: awk BuildRoot: %{_tmppath}/%{name}_%{version}-build @@ -40,7 +41,10 @@ rm -rf %{buildroot} mkdir -p %{buildroot}/%{_mandir}/man1 install -m644 docs/man/%{name}.1 %{buildroot}/%{_mandir}/man1 +install -d -m0755 %{buildroot}/%{_sysconfdir}/bash_completion.d/ +install -Dp -m0755 etc/bash_completion.d/%{name} %{buildroot}/%{_sysconfdir}/bash_completion.d/ %files %{_bindir}/%{name} %{_mandir}/man1/* +%{_sysconfdir}/bash_completion.d/* |