feat(help): header-driven --help for terminal and session functions
spwin, tab, hist, bkg, wake-lock and fc take the standard first-arg-only call site, so `wake-lock rsync --help` still runs rsync. split takes --help only: its own ARGUMENTS documents -h as --horizontal, so a literal test replaces the renderer's own flag check. Verified that `split -h` still selects a horizontal split and never prints help.
This commit is contained in:
@@ -23,6 +23,8 @@
|
|||||||
# EXAMPLE
|
# EXAMPLE
|
||||||
# bkg firefox
|
# bkg firefox
|
||||||
function bkg --description 'Execute bkg'
|
function bkg --description 'Execute bkg'
|
||||||
|
__fish_help_header (status current-function) $argv; and return 0
|
||||||
|
|
||||||
# Check if a command was provided as an argument.
|
# Check if a command was provided as an argument.
|
||||||
if test -z "$argv[1]"
|
if test -z "$argv[1]"
|
||||||
set -l c_head (set_color --bold cyan)
|
set -l c_head (set_color --bold cyan)
|
||||||
|
|||||||
@@ -24,6 +24,8 @@
|
|||||||
# fc
|
# fc
|
||||||
# fc git
|
# fc git
|
||||||
function fc --description 'Edit and execute the last command (Bash-style fc)'
|
function fc --description 'Edit and execute the last command (Bash-style fc)'
|
||||||
|
__fish_help_header (status current-function) $argv; and return 0
|
||||||
|
|
||||||
set -l tmpfile (mktemp /tmp/fish_fc.XXXXXX).fish
|
set -l tmpfile (mktemp /tmp/fish_fc.XXXXXX).fish
|
||||||
|
|
||||||
if count $argv >/dev/null
|
if count $argv >/dev/null
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
# EXAMPLE
|
# EXAMPLE
|
||||||
# hist
|
# hist
|
||||||
function hist --description 'Search fish history and put it in the prompt'
|
function hist --description 'Search fish history and put it in the prompt'
|
||||||
|
__fish_help_header (status current-function) $argv; and return 0
|
||||||
|
|
||||||
# Opinionated guard (C4): integrations disabled
|
# Opinionated guard (C4): integrations disabled
|
||||||
if not __fish_config_op_enabled (status current-function)
|
if not __fish_config_op_enabled (status current-function)
|
||||||
set -l c_err (set_color red)
|
set -l c_err (set_color red)
|
||||||
|
|||||||
@@ -29,6 +29,10 @@
|
|||||||
# split
|
# split
|
||||||
# split -v nvim README.md
|
# split -v nvim README.md
|
||||||
function split --description 'Run a command in a new terminal split'
|
function split --description 'Run a command in a new terminal split'
|
||||||
|
# -h is --horizontal here (see this function's own ARGUMENTS),
|
||||||
|
# so only the long form may reach the renderer.
|
||||||
|
test "$argv[1]" = --help; and __fish_help_header (status current-function) --help; and return 0
|
||||||
|
|
||||||
# Opinionated guard (C4): integrations disabled
|
# Opinionated guard (C4): integrations disabled
|
||||||
if not __fish_config_op_enabled (status current-function)
|
if not __fish_config_op_enabled (status current-function)
|
||||||
set -l c_err (set_color red)
|
set -l c_err (set_color red)
|
||||||
|
|||||||
@@ -24,6 +24,8 @@
|
|||||||
# EXAMPLE
|
# EXAMPLE
|
||||||
# spwin
|
# spwin
|
||||||
function spwin --wraps='~/.config/kitty/spawn-window.sh' --description 'spawn window in kitty or wezterm'
|
function spwin --wraps='~/.config/kitty/spawn-window.sh' --description 'spawn window in kitty or wezterm'
|
||||||
|
__fish_help_header (status current-function) $argv; and return 0
|
||||||
|
|
||||||
# Opinionated guard (C4): integrations disabled
|
# Opinionated guard (C4): integrations disabled
|
||||||
if not __fish_config_op_enabled (status current-function)
|
if not __fish_config_op_enabled (status current-function)
|
||||||
set -l c_err (set_color red)
|
set -l c_err (set_color red)
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
# EXAMPLE
|
# EXAMPLE
|
||||||
# tab
|
# tab
|
||||||
function tab --description 'Spawn a new tab in the current terminal'
|
function tab --description 'Spawn a new tab in the current terminal'
|
||||||
|
__fish_help_header (status current-function) $argv; and return 0
|
||||||
|
|
||||||
# Opinionated guard (C4): integrations disabled
|
# Opinionated guard (C4): integrations disabled
|
||||||
if not __fish_config_op_enabled (status current-function)
|
if not __fish_config_op_enabled (status current-function)
|
||||||
set -l c_err (set_color red)
|
set -l c_err (set_color red)
|
||||||
|
|||||||
@@ -22,6 +22,8 @@
|
|||||||
# EXAMPLE
|
# EXAMPLE
|
||||||
# wake-lock rsync -avz src/ dest/
|
# wake-lock rsync -avz src/ dest/
|
||||||
function wake-lock --description 'Run a command while inhibiting system sleep'
|
function wake-lock --description 'Run a command while inhibiting system sleep'
|
||||||
|
__fish_help_header (status current-function) $argv; and return 0
|
||||||
|
|
||||||
if test (count $argv) -eq 0
|
if test (count $argv) -eq 0
|
||||||
set -l c_head (set_color --bold cyan)
|
set -l c_head (set_color --bold cyan)
|
||||||
set -l c_cmd (set_color --bold)
|
set -l c_cmd (set_color --bold)
|
||||||
|
|||||||
Reference in New Issue
Block a user