mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-23 17:33:01 +02:00
src/klish-plugin-infix: use shell pager instead of klish pager
With interactive mode (out="tty") klish puts the tty in raw mode which fixes all weird issues reported around paged output in the CLI. Fixes #659 Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
@@ -177,34 +177,48 @@
|
||||
|
||||
<COMMAND name="show" help="Show system status and configuration files" mode="switch">
|
||||
<COMMAND name="container" help="Show container status">
|
||||
<ACTION sym="script">doas container show</ACTION>
|
||||
<ACTION sym="script" in="tty" out="tty" interrupt="true">
|
||||
doas container show |pager
|
||||
</ACTION>
|
||||
|
||||
<SWITCH name="optional" min="0">
|
||||
<COMMAND name="all" help="Show all containers (default only running)">
|
||||
<ACTION sym="script">doas container -a show</ACTION>
|
||||
</COMMAND>
|
||||
<COMMAND name="log" help="Show container log (alias for show log container)">
|
||||
<ACTION sym="script">doas -u $USER cat /log/container</ACTION>
|
||||
<ACTION sym="script" in="tty" out="tty" interrupt="true">
|
||||
doas -u $USER cat /log/container |pager
|
||||
</ACTION>
|
||||
</COMMAND>
|
||||
<COMMAND name="images" help="Show container images">
|
||||
<ACTION sym="script">doas container show images</ACTION>
|
||||
<SWITCH name="optional" min="0">
|
||||
<COMMAND name="all" help="All images (default hides intermediate imaages)">
|
||||
<ACTION sym="script">doas container -a show images</ACTION>
|
||||
<ACTION sym="script" in="tty" out="tty" interrupt="true">
|
||||
doas container -a show images |pager
|
||||
</ACTION>
|
||||
</COMMAND>
|
||||
</SWITCH>
|
||||
</COMMAND>
|
||||
<COMMAND name="oci" help="Show OCI archives (for loading as image)">
|
||||
<ACTION sym="script">doas container list oci</ACTION>
|
||||
<ACTION sym="script" in="tty" out="tty" interrupt="true">
|
||||
doas container list oci |pager
|
||||
</ACTION>
|
||||
</COMMAND>
|
||||
<COMMAND name="stat" help="Show continuous containers stats (Ctrl-C aborts)">
|
||||
<ACTION sym="script">doas container stat</ACTION>
|
||||
<ACTION sym="script" in="tty" out="tty" interrupt="true">
|
||||
doas container stat
|
||||
</ACTION>
|
||||
</COMMAND>
|
||||
<COMMAND name="usage" help="Show container resource usage">
|
||||
<ACTION sym="script">doas podman system df -v</ACTION>
|
||||
<ACTION sym="script" in="tty" out="tty" interrupt="true">
|
||||
doas podman system df -v
|
||||
</ACTION>
|
||||
</COMMAND>
|
||||
<COMMAND name="volumes" help="Show container volumes">
|
||||
<ACTION sym="script">doas container show volumes</ACTION>
|
||||
<ACTION sym="script" in="tty" out="tty" interrupt="true">
|
||||
doas container show volumes |pager
|
||||
</ACTION>
|
||||
</COMMAND>
|
||||
</SWITCH>
|
||||
</COMMAND>
|
||||
|
||||
@@ -133,11 +133,11 @@
|
||||
<ACTION sym="printl">upgrade</ACTION>
|
||||
</COMPL>
|
||||
</PARAM>
|
||||
<ACTION sym="script">
|
||||
<ACTION sym="script" in="tty" out="tty" interrupt="true">
|
||||
topic=${KLISH_PARAM_topic:-quick}
|
||||
fn="/usr/share/infix/cli/${topic}.md"
|
||||
if [ -f "$fn" ]; then
|
||||
lowdown -t term --term-vmargin=1 "$fn"
|
||||
lowdown -t term --term-vmargin=1 "$fn" |pager
|
||||
else
|
||||
echo "Help topic not available, try help without an argument, or tap '?' for a list."
|
||||
fi
|
||||
@@ -226,27 +226,36 @@
|
||||
<COMMAND name="show" help="Show system status and configuration files" mode="switch">
|
||||
|
||||
<COMMAND name="bridge" help="Show bridge (ports/fdb/mdb/vlans)">
|
||||
<ACTION sym="script">bridge -color link</ACTION>
|
||||
<ACTION sym="script" in="tty" out="tty" interrupt="true">
|
||||
bridge -color link |pager
|
||||
</ACTION>
|
||||
|
||||
<SWITCH name="optional" min="0">
|
||||
<COMMAND name="fdb" help="Show unicast forwarding database">
|
||||
<ACTION sym="script">bridge -color fdb</ACTION>
|
||||
<ACTION sym="script" in="tty" out="tty" interrupt="true">
|
||||
bridge -color fdb |pager
|
||||
</ACTION>
|
||||
</COMMAND>
|
||||
<COMMAND name="mdb" help="Show mulficast forwarding database">
|
||||
<SWITCH name="optional" min="0">
|
||||
<COMMAND name="detailed" help="Detailed (full) output">
|
||||
<ACTION sym="script">bridge -color -d mdb</ACTION>
|
||||
<ACTION sym="script" in="tty" out="tty" interrupt="true">
|
||||
bridge -color -d mdb |pager
|
||||
</ACTION>
|
||||
</COMMAND>
|
||||
</SWITCH>
|
||||
<ACTION sym="script"> sysrepocfg -d operational -X -f json -x /ietf-interfaces:interfaces | \
|
||||
/usr/libexec/statd/cli-pretty show-bridge-mdb
|
||||
<ACTION sym="script" in="tty" out="tty" interrupt="true">
|
||||
sysrepocfg -d operational -X -f json -x /ietf-interfaces:interfaces | \
|
||||
/usr/libexec/statd/cli-pretty show-bridge-mdb |pager
|
||||
</ACTION>
|
||||
</COMMAND>
|
||||
<COMMAND name="vlan" help="Show VLAN table">
|
||||
<ACTION sym="script">bridge -color vlan</ACTION>
|
||||
<SWITCH name="optional" min="0">
|
||||
<COMMAND name="detailed" help="Detailed (full) output">
|
||||
<ACTION sym="script">bridge -color -d vlan</ACTION>
|
||||
<ACTION sym="script" in="tty" out="tty" interrupt="true">
|
||||
bridge -color -d vlan |pager
|
||||
</ACTION>
|
||||
</COMMAND>
|
||||
</SWITCH>
|
||||
</COMMAND>
|
||||
@@ -264,7 +273,9 @@
|
||||
|
||||
<COMMAND name="dns" help="Show DNS (client) status">
|
||||
<!-- Show static/configured nameservers and then all learned ones from DHCP clients -->
|
||||
<ACTION sym="script">cat /etc/resolv.conf.head 2>/dev/null; resolvconf -l | sed 's/#.*//; /^\s*$/d'</ACTION>
|
||||
<ACTION sym="script" in="tty" out="tty" interrupt="true">
|
||||
cat /etc/resolv.conf.head 2>/dev/null; resolvconf -l | sed 's/#.*//; /^\s*$/d' |pager
|
||||
</ACTION>
|
||||
</COMMAND>
|
||||
|
||||
<COMMAND name="ntp" help="Show NTP (client) status">
|
||||
@@ -306,19 +317,19 @@
|
||||
<ACTION sym="printl">bfd</ACTION>
|
||||
</COMPL>
|
||||
</PARAM>
|
||||
<ACTION sym="script">
|
||||
<ACTION sym="script" in="tty" out="tty" interrupt="true">
|
||||
if [ -z "$KLISH_PARAM_name" ]; then
|
||||
doas vtysh -c "show ip ospf"
|
||||
doas vtysh -c "show ip ospf" |pager
|
||||
elif [ "$KLISH_PARAM_name" == "neighbor" ];then
|
||||
doas vtysh -c "show ip ospf neighbor"
|
||||
doas vtysh -c "show ip ospf neighbor" |pager
|
||||
elif [ "$KLISH_PARAM_name" == "interfaces" ];then
|
||||
doas vtysh -c "show ip ospf interface"
|
||||
doas vtysh -c "show ip ospf interface" |pager
|
||||
elif [ "$KLISH_PARAM_name" == "routes" ];then
|
||||
doas vtysh -c "show ip ospf route"
|
||||
doas vtysh -c "show ip ospf route" |pager
|
||||
elif [ "$KLISH_PARAM_name" == "database" ];then
|
||||
doas vtysh -c "show ip ospf database"
|
||||
doas vtysh -c "show ip ospf database" |pager
|
||||
elif [ "$KLISH_PARAM_name" == "bfd" ];then
|
||||
doas vtysh -c "show bfd peers"
|
||||
doas vtysh -c "show bfd peers" |pager
|
||||
fi
|
||||
</ACTION>
|
||||
</COMMAND>
|
||||
@@ -330,7 +341,7 @@
|
||||
<ACTION sym="printl">ipv6</ACTION>
|
||||
</COMPL>
|
||||
</PARAM>
|
||||
<ACTION sym="script">
|
||||
<ACTION sym="script" in="tty" out="tty" interrupt="true">
|
||||
case $KLISH_PARAM_ip in
|
||||
ipv4)
|
||||
KLISH_PARAM_ip=ip
|
||||
@@ -339,14 +350,14 @@
|
||||
KLISH_PARAM_ip=ipv6
|
||||
;;
|
||||
esac
|
||||
show -p $KLISH_PARAM_ip route
|
||||
show -p $KLISH_PARAM_ip route |pager
|
||||
</ACTION>
|
||||
</COMMAND>
|
||||
|
||||
<COMMAND name="hardware" help="Show hardware information">
|
||||
<ACTION sym="script">
|
||||
<ACTION sym="script" in="tty" out="tty" interrupt="true">
|
||||
sysrepocfg -f json -X -d operational -x "/ietf-hardware:hardware" | \
|
||||
/usr/libexec/statd/cli-pretty "show-hardware"
|
||||
/usr/libexec/statd/cli-pretty "show-hardware" |pager
|
||||
</ACTION>
|
||||
</COMMAND>
|
||||
|
||||
@@ -358,46 +369,60 @@
|
||||
</PARAM>
|
||||
</COMMAND>
|
||||
</SWITCH>
|
||||
<ACTION sym="script">
|
||||
<ACTION sym="script" in="tty" out="tty" interrupt="true">
|
||||
if [ -n "$KLISH_PARAM_name" ]; then
|
||||
sysrepocfg -f json -X -d operational -x \
|
||||
"/ietf-interfaces:interfaces/interface[name=\"$KLISH_PARAM_name\"]" | \
|
||||
/usr/libexec/statd/cli-pretty "show-interfaces" -n "$KLISH_PARAM_name"
|
||||
/usr/libexec/statd/cli-pretty "show-interfaces" -n "$KLISH_PARAM_name" |pager
|
||||
else
|
||||
sysrepocfg -f json -X -d operational -m ietf-interfaces | \
|
||||
/usr/libexec/statd/cli-pretty "show-interfaces"
|
||||
/usr/libexec/statd/cli-pretty "show-interfaces" |pager
|
||||
fi
|
||||
</ACTION>
|
||||
</COMMAND>
|
||||
|
||||
<COMMAND name="ip" help="Show IP level status (Layer-3)">
|
||||
<ACTION sym="script">ip -color addr</ACTION>
|
||||
<ACTION sym="script" in="tty" out="tty" interrupt="true">
|
||||
ip -color addr |pager
|
||||
</ACTION>
|
||||
|
||||
<SWITCH name="optional" min="0">
|
||||
<COMMAND name="brief" help="Simplified (human-readable) output" mode="switch">
|
||||
<ACTION sym="script">ip -color -br addr | sort -V | sed 's/@dsa[0-9]/ /'</ACTION>
|
||||
<ACTION sym="script" in="tty" out="tty" interrupt="true">
|
||||
ip -color -br addr | sort -V | sed 's/@dsa[0-9]/ /' |pager
|
||||
</ACTION>
|
||||
</COMMAND>
|
||||
|
||||
<COMMAND name="detailed" help="Detailed (full) output" mode="switch">
|
||||
<ACTION sym="script">ip -color -d addr</ACTION>
|
||||
<ACTION sym="script" in="tty" out="tty" interrupt="true">
|
||||
ip -color -d addr |pager
|
||||
</ACTION>
|
||||
</COMMAND>
|
||||
|
||||
<COMMAND name="multicast" help="Show IGMP/MLD status" mode="switch">
|
||||
<ACTION sym="script">mctl</ACTION>
|
||||
<ACTION sym="script" in="tty" out="tty" interrupt="true">
|
||||
mctl |pager
|
||||
</ACTION>
|
||||
</COMMAND>
|
||||
|
||||
<COMMAND name="route" help="Show IPv4 routing table" mode="switch">
|
||||
<ACTION sym="script">show -p ip route</ACTION>
|
||||
<ACTION sym="script" in="tty" out="tty" interrupt="true">
|
||||
show -p ip route |pager
|
||||
</ACTION>
|
||||
</COMMAND>
|
||||
</SWITCH>
|
||||
</COMMAND>
|
||||
|
||||
<COMMAND name="ipv6" help="Show IPv6 level status (Layer-3)">
|
||||
<ACTION sym="script">ip -color -6 addr</ACTION>
|
||||
<ACTION sym="script" in="tty" out="tty" interrupt="true">
|
||||
ip -color -6 addr |pager
|
||||
</ACTION>
|
||||
|
||||
<SWITCH name="optional" min="0">
|
||||
<COMMAND name="route" help="Show IPv6 routing table" mode="switch">
|
||||
<ACTION sym="script">show -p ipv6 route</ACTION>
|
||||
<ACTION sym="script" in="tty" out="tty" interrupt="true">
|
||||
show -p ipv6 route |pager
|
||||
</ACTION>
|
||||
</COMMAND>
|
||||
</SWITCH>
|
||||
</COMMAND>
|
||||
@@ -409,7 +434,7 @@
|
||||
<PARAM name="lines" ptype="/UINT" help="Last number of lines to show"/>
|
||||
</COMMAND>
|
||||
</SWITCH>
|
||||
<ACTION sym="script">
|
||||
<ACTION sym="script" in="tty" out="tty" interrupt="true">
|
||||
file=/log/${KLISH_PARAM_fn:-syslog}
|
||||
case "$file" in
|
||||
*.gz)
|
||||
@@ -422,7 +447,7 @@
|
||||
if [ -n "$KLISH_PARAM_lines" ]; then
|
||||
$cmd "$file" | tail -n $KLISH_PARAM_lines
|
||||
else
|
||||
$cmd "$file"
|
||||
$cmd "$file" | pager
|
||||
fi
|
||||
</ACTION>
|
||||
</COMMAND>
|
||||
@@ -436,24 +461,26 @@
|
||||
</COMMAND>
|
||||
-->
|
||||
<COMMAND name="version" help="Show software version">
|
||||
<ACTION sym="script">cat /etc/version</ACTION>
|
||||
<ACTION sym="script" in="tty" interrupt="true">cat /etc/version</ACTION>
|
||||
</COMMAND>
|
||||
|
||||
<COMMAND name="factory-config" help="Show factory-config">
|
||||
<ACTION sym="script">jq -C . /etc/factory-config.cfg</ACTION>
|
||||
<ACTION sym="script" in="tty" out="tty" interrupt="true">jq -C . /etc/factory-config.cfg |pager</ACTION>
|
||||
</COMMAND>
|
||||
|
||||
<COMMAND name="running-config" help="Show running-config">
|
||||
<ACTION sym="script">sysrepocfg -X -f json | jq -C .</ACTION>
|
||||
<ACTION sym="script" in="tty" out="tty" interrupt="true">sysrepocfg -X -f json | jq -C . |pager</ACTION>
|
||||
</COMMAND>
|
||||
|
||||
<COMMAND name="startup-config" help="Show startup-config">
|
||||
<ACTION sym="script">jq -C . /cfg/startup-config.cfg</ACTION>
|
||||
<ACTION sym="script" in="tty" out="tty" interrupt="true">jq -C . /cfg/startup-config.cfg |pager</ACTION>
|
||||
</COMMAND>
|
||||
</COMMAND>
|
||||
<COMMAND name="factory-reset" help="Restore the system to factory default state">
|
||||
<ACTION sym="script" in="tty" out="tty" interrupt="true">/bin/yorn "This will restore the device to factory defaults"</ACTION>
|
||||
<ACTION sym="srp_rpc@sysrepo">/ietf-factory-default:factory-reset</ACTION>
|
||||
<ACTION sym="script" in="tty" out="tty" interrupt="true">
|
||||
/bin/yorn "This will restore the device to factory defaults"
|
||||
</ACTION>
|
||||
<ACTION sym="srp_rpc@sysrepo">/ietf-factory-default:factory-reset</ACTION>
|
||||
</COMMAND>
|
||||
|
||||
<COMMAND name="follow" help="Monitor a log file, use Ctrl-C to abort">
|
||||
@@ -469,7 +496,7 @@
|
||||
<PARAM name="addrlen" ptype="/STRING" help="ADDRESS[/LEN]"/>
|
||||
<PARAM name="netmask" ptype="/STRING" min="0" help="Optional NETMASK"/>
|
||||
<PARAM name="split" ptype="/UINT" min="0" help="Split network: 1-32 (IPv4), 1-128 (IPv6)"/>
|
||||
<ACTION sym="script">
|
||||
<ACTION sym="script" in="tty" out="tty" interrupt="true">
|
||||
if [ -n "$KLISH_PARAM_split" ]; then
|
||||
if echo $KLISH_PARAM_addrlen |grep -q ':'; then
|
||||
split="-S $KLISH_PARAM_split"
|
||||
|
||||
Reference in New Issue
Block a user