fish: try out argparse on port listener
This reverts commit f11ed4a3c81e6963704e8f8b2f086c4509d54255.
This commit is contained in:
parent
9cb8a21a2c
commit
42be4ad809
@ -1,7 +1,16 @@
|
|||||||
function port_listener --argument-names port
|
function port_listener
|
||||||
if test -n "$port"
|
argparse 'h/help' 'p#port' 'S/sudo' -- $argv
|
||||||
lsof -n -i :$port | rg LISTEN
|
|
||||||
else
|
if test -n "$_flag_help"
|
||||||
lsof -n -i | rg LISTEN
|
echo "Usage: port_listener [-h] [--help] [-p <port>] [--port=<port>] [-S] [--sudo]"
|
||||||
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
set -q _flag_sudo; and set -l _pl_cmd_prefix "sudo "
|
||||||
|
set -q _flag_port; and set -l _pl_cmd_suffix " :$_flag_port"
|
||||||
|
|
||||||
|
set -l _port_listener_cmd (printf '%s%s%s | rg LISTEN' $_pl_cmd_prefix 'lsof -n -P -i' $_pl_cmd_suffix)
|
||||||
|
|
||||||
|
echo $_port_listener_cmd
|
||||||
|
eval $_port_listener_cmd
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user