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
|
||||
if test -n "$port"
|
||||
lsof -n -i :$port | rg LISTEN
|
||||
else
|
||||
lsof -n -i | rg LISTEN
|
||||
function port_listener
|
||||
argparse 'h/help' 'p#port' 'S/sudo' -- $argv
|
||||
|
||||
if test -n "$_flag_help"
|
||||
echo "Usage: port_listener [-h] [--help] [-p <port>] [--port=<port>] [-S] [--sudo]"
|
||||
return 0
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user