summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--etc/bash_completion.d/10vyatta-op28
-rw-r--r--templates/terminal/length/node.def1
-rw-r--r--templates/terminal/length/node.tag/node.def7
-rw-r--r--templates/terminal/node.def1
-rw-r--r--templates/terminal/pager/node.def2
-rw-r--r--templates/terminal/pager/node.tag/node.def3
-rw-r--r--templates/terminal/width/node.def1
-rw-r--r--templates/terminal/width/node.tag/node.def3
8 files changed, 40 insertions, 6 deletions
diff --git a/etc/bash_completion.d/10vyatta-op b/etc/bash_completion.d/10vyatta-op
index 0651618..dacf57f 100644
--- a/etc/bash_completion.d/10vyatta-op
+++ b/etc/bash_completion.d/10vyatta-op
@@ -22,6 +22,17 @@
#
# **** End License ****
+declare -r _vyatta_default_pager="less\
+ --QUIT-AT-EOF\
+ --quit-if-one-screen\
+ --LONG-PROMPT\
+ --RAW-CONTROL-CHARS\
+ --squeeze-blank-lines\
+ --buffers=64\
+ --auto-buffers\
+ --no-lessopen"
+declare -x VYATTA_PAGER=$_vyatta_default_pager
+
test -f /etc/default/vyatta && \
source /etc/default/vyatta
@@ -147,7 +158,7 @@ _vyatta_op_help ()
_vyatta_op_compreply ()
{
local cur=$1; shift
- local -a comps justhelp
+ local -a justhelp comps scomps
# donot complete entries like <HOSTNAME> or <A.B.C.D>
for allow ; do
@@ -158,7 +169,9 @@ _vyatta_op_compreply ()
fi
done
- COMPREPLY=($( compgen -W "${comps[*]}" -- $cur ))
+ scomps=($( printf "%s\n" ${comps[@]} | sort -u ))
+
+ COMPREPLY=($( compgen -W "${scomps[*]}" -- $cur ))
# if the last command line arg is empty and we have
# an empty completion option (meaning wild card),
@@ -176,9 +189,8 @@ _vyatta_op_compreply ()
fi
if [ "${COMP_WORDS[*]}" == "$_vyatta_op_last_comp" ] ; then
- _vyatta_op_help "$cur" "$node_path" \
- ${justhelp[@]} \
- $(printf "%s\n" ${comps[@]} | sort)
+ _vyatta_op_help "$cur" "$node_path" ${justhelp[@]} ${scomps[@]} | \
+ eval ${VYATTA_PAGER:-cat}
COMPREPLY=( "" " " )
_vyatta_op_last_comp=""
else
@@ -254,7 +266,11 @@ _vyatta_op_run ()
local run_cmd=$(_vyatta_op_get_node_def_field $tpath/node.def run)
local ret=0
if [ -n "$run_cmd" ]; then
- eval "$run_cmd"
+ if [ "$1" == "show" ] ; then
+ ( eval "$run_cmd" ) | eval "${VYATTA_PAGER:-cat}"
+ else
+ eval "$run_cmd"
+ fi
else
echo "Incomplete command" >&2
ret=1
diff --git a/templates/terminal/length/node.def b/templates/terminal/length/node.def
new file mode 100644
index 0000000..3e24898
--- /dev/null
+++ b/templates/terminal/length/node.def
@@ -0,0 +1 @@
+help: Set terminal rows
diff --git a/templates/terminal/length/node.tag/node.def b/templates/terminal/length/node.tag/node.def
new file mode 100644
index 0000000..3dfae2b
--- /dev/null
+++ b/templates/terminal/length/node.tag/node.def
@@ -0,0 +1,7 @@
+help: Set terminal to given number of rows (0 disables paging)
+allowed: echo -n '<NUMBER>'
+run: if [ "$3" -eq 0 ] ; then
+ VYATTA_PAGER=cat
+ else
+ stty rows $3
+ fi
diff --git a/templates/terminal/node.def b/templates/terminal/node.def
new file mode 100644
index 0000000..85b7c7f
--- /dev/null
+++ b/templates/terminal/node.def
@@ -0,0 +1 @@
+help: Control terminal paging
diff --git a/templates/terminal/pager/node.def b/templates/terminal/pager/node.def
new file mode 100644
index 0000000..cb5cb41
--- /dev/null
+++ b/templates/terminal/pager/node.def
@@ -0,0 +1,2 @@
+help: Use default pager (less)
+run: VYATTA_PAGER=
diff --git a/templates/terminal/pager/node.tag/node.def b/templates/terminal/pager/node.tag/node.def
new file mode 100644
index 0000000..fe2226e
--- /dev/null
+++ b/templates/terminal/pager/node.tag/node.def
@@ -0,0 +1,3 @@
+help: Set terminal pager
+allowed: echo -n '<PROGRAM>'
+run: VYATTA_PAGER=$3
diff --git a/templates/terminal/width/node.def b/templates/terminal/width/node.def
new file mode 100644
index 0000000..ddbc07d
--- /dev/null
+++ b/templates/terminal/width/node.def
@@ -0,0 +1 @@
+help: Set terminal columns
diff --git a/templates/terminal/width/node.tag/node.def b/templates/terminal/width/node.tag/node.def
new file mode 100644
index 0000000..c40bfd7
--- /dev/null
+++ b/templates/terminal/width/node.tag/node.def
@@ -0,0 +1,3 @@
+help: Set terminal to given number of columns
+allowed: echo -n '<NUMBER>'
+run: stty columns $3