blob: 7d69913a69c84b699214547aab3c22f8942bb684 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
This package has the Vyatta operational command completion script and
base template tree. The default root of this tree is:
/opt/vyatta/share/vyatta-op/templates
Each directory within this tree is a respective command line argument;
for example, the .../templates/show/interfaces/ethernet directory
completes the command line "show interfaces ethernet". Thus, the
directory name is generally equivalent to the command or argument
name. The only exception are directories named "node.tag"; these
represent dynamic or variable command arguments. For example,
.../templates/show/interfaces/ethernet/node.tag completes the active
system interfaces like "show interfaces ethernet eth0".
Every template directory must have one and only one file named
"node.def". This file defines the node help string and run command,
like .../templates/show/interfaces/node.def:
help: "Show network interface information"
run: ${vyatta_bindir}/vyatta-show-interfaces
Notes:
- field tags (i.e. help and run) must be at the start of line
- try to limit help strings to 64 characters
- run commands may span multiple lines but subsequent lines must
not begin with "WORD:"
The run command is an evaluated shell expression that may contain the
positional command line argument variables (i.e. $1, $*, $@).
However, since the command itself, is evaluated through an aliased
function, $1 is the command name rather than the usual $0. So, the
command "show interfaces ethernet eth0" would evaluate the respective
run command with $4 == eth0.
The variable argument .../node.tag/node.def files may also define an
"allowed" field. This is a misnomer since it's really used to produce
a list of possible completions rather than what is allowed during
execution. The fields contents are evaluated shell expression that
outputs (stdout) the list of possible completion values; like
.../templates/show/interfaces/ethernet/node.tag/node.def:
help: "Show given ethernet interface information"
allowed: local -a array=( /sys/class/net/{eth,vmnet}* ) ;
echo -n ${array[@]##*/}
run: ${vyatta_bindir}/vyatta-show-interfaces ethernet $4
A blank or missing "allowed" field means that there is no completion
for the respective node; for such nodes a '*' placeholder tag is
displayed with the help text.
|