aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--build-data/platforms.mk8
-rw-r--r--build-root/rpm/vpp.spec6
-rw-r--r--src/Makefile.am8
-rw-r--r--src/scripts/vppctl_completion30
5 files changed, 55 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 61c407ff..ab997faa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -88,3 +88,6 @@ GTAGS
# Build files in the test directory
/test/*.ok
+
+# vppctl command list
+/src/scripts/vppctl-cmd-list
diff --git a/build-data/platforms.mk b/build-data/platforms.mk
index e192155b..41836750 100644
--- a/build-data/platforms.mk
+++ b/build-data/platforms.mk
@@ -75,6 +75,14 @@ install-deb: $(patsubst %,%-find-source,$(ROOT_PACKAGES))
echo ../../src/vpp/conf/80-vpp.conf /etc/sysctl.d \
>> deb/debian/vpp.install ; \
\
+ : bash completion for vppctl ; \
+ echo ../../src/scripts/vppctl_completion /etc/bash_completion.d \
+ >> deb/debian/vpp.install ; \
+ \
+ : move dictionary of vppctl commands ; \
+ echo ../../src/scripts/vppctl-cmd-list /usr/share/vpp \
+ >> deb/debian/vpp.install ; \
+ \
: dev package needs a couple of additions ; \
echo ../$(INSTALL_PREFIX)$(ARCH)/vpp/bin/vppapigen /usr/bin \
>> deb/debian/vpp-dev.install ; \
diff --git a/build-root/rpm/vpp.spec b/build-root/rpm/vpp.spec
index b63d3e17..8308dbf5 100644
--- a/build-root/rpm/vpp.spec
+++ b/build-root/rpm/vpp.spec
@@ -125,6 +125,8 @@ install -p -m 644 %{_mu_build_dir}/../src/vpp/conf/80-vpp.conf %{buildroot}/etc/
# libraries
#
mkdir -p -m755 %{buildroot}%{_libdir}
+mkdir -p -m755 %{buildroot}/etc/bash_completion.d
+mkdir -p -m755 %{buildroot}/usr/share/vpp
for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/*/lib* -type f -name '*.so.*.*.*' -print )
do
install -p -m 755 $file %{buildroot}%{_libdir}
@@ -141,6 +143,8 @@ for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/vpp/share/vpp/api -type
do
install -p -m 644 $file %{buildroot}/usr/share/vpp/api
done
+install -p -m 644 %{_mu_build_dir}/../src/scripts/vppctl_completion %{buildroot}/etc/bash_completion.d
+install -p -m 644 %{_mu_build_dir}/../src/scripts/vppctl-cmd-list %{buildroot}/usr/share/vpp
# Lua bindings
mkdir -p -m755 %{buildroot}/usr/share/doc/vpp/examples/lua/examples/cli
@@ -269,6 +273,8 @@ fi
%exclude %{_libdir}/vpp_api_test_plugins
%{_libdir}/*
/usr/share/vpp/api/*
+/etc/bash_completion.d/vppctl_completion
+/usr/share/vpp/vppctl-cmd-list
%files api-lua
%defattr(644,root,root)
diff --git a/src/Makefile.am b/src/Makefile.am
index 18a41a15..227accc0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -28,6 +28,14 @@ noinst_HEADERS =
dist_bin_SCRIPTS =
lib_LTLIBRARIES =
BUILT_SOURCES =
+install-data-local:
+ @echo "Building vppctl command list..."
+ @DIR_SEARCH="$(srcdir)" ; \
+ DIR_EXCLUDE="examples" ; \
+ GREP_TIME=`time (grep -wIr "\.path = " $$DIR_SEARCH --exclude-dir=$$DIR_EXCLUDE \
+ | cut -d '"' -f2 | sort -u > $(srcdir)/scripts/vppctl-cmd-list) 2>&1` ; \
+ GREP_TIME=`echo $$GREP_TIME | awk '{print $$2}'` ; \
+ echo "Command list built, Time taken: $$GREP_TIME"
###############################################################################
# DPDK
diff --git a/src/scripts/vppctl_completion b/src/scripts/vppctl_completion
new file mode 100644
index 00000000..2a64e9ab
--- /dev/null
+++ b/src/scripts/vppctl_completion
@@ -0,0 +1,30 @@
+#Copyright 2017 Intel Corporation
+#
+#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.
+
+_vppctl()
+{
+ local cur prev num opts
+ COMPREPLY=( $(compgen -f ${cur}) )
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[@]:1}"
+ num="$((${#COMP_WORDS[@]}-1))"
+
+ VPP_CMD_LIST="$(cat /usr/share/vpp/vppctl-cmd-list)"
+
+ opts="$(awk -v prev="^$prev" -v num=$num '{if($0 ~ prev) print $num}' <<< "${VPP_CMD_LIST}")"
+
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+
+}
+complete -F _vppctl vppctl