fix(functions): split dops.fish into dops and docker
dops.fish defined `docker`, not `dops`. dops was never defined; docker was only conditionally defined as a side effect of the failed dops autoload, so its behavior could silently change mid-session. See JOB-BRIEF-FINDINGS.md §1. - functions/dops.fish now defines dops: a real enhanced `docker ps` listing (custom Names/Image/Status/Ports table), with its own --help. - functions/docker.fish is a new file holding the ps-redirect wrapper, fixed to actually call dops (previously called the still-undefined dops from inside itself). - Bare `docker` with no arguments no longer falls through an if-with-no-else (the fish false-zero, AGENTS.md standing gotcha #5) and does nothing; it now runs the real docker binary, which prints its own usage. - tests/functional.fish: updated the now-stale comment explaining why the help-flag check resolves the real function name instead of the file stem.
This commit is contained in:
@@ -0,0 +1,41 @@
|
|||||||
|
# Copyright (C) 2026 Rootiest
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
# CATEGORY
|
||||||
|
# 12-ai-and-developer-tools
|
||||||
|
#
|
||||||
|
# DEPENDENCIES
|
||||||
|
# dops
|
||||||
|
#
|
||||||
|
# SYNOPSIS
|
||||||
|
# docker [subcommand] [args...]
|
||||||
|
#
|
||||||
|
# DESCRIPTION
|
||||||
|
# Wrapper for docker that intercepts the ps subcommand and redirects it to
|
||||||
|
# the dops function for enhanced container listing. All other subcommands,
|
||||||
|
# and a bare invocation with no subcommand, are passed through to the real
|
||||||
|
# docker binary.
|
||||||
|
#
|
||||||
|
# ARGUMENTS
|
||||||
|
# subcommand Docker subcommand (ps is redirected to dops)
|
||||||
|
# args... Arguments forwarded to docker or dops
|
||||||
|
#
|
||||||
|
# EXIT STATUS
|
||||||
|
# Exit status of dops (for ps), or of the real docker binary otherwise
|
||||||
|
#
|
||||||
|
# EXAMPLE
|
||||||
|
# docker ps
|
||||||
|
# docker
|
||||||
|
function docker --description 'Execute docker, redirecting ps to the enhanced dops listing'
|
||||||
|
if test -z "$argv[1]"
|
||||||
|
command docker
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
switch $argv[1]
|
||||||
|
case ps
|
||||||
|
dops $argv[2..-1]
|
||||||
|
case '*'
|
||||||
|
command docker $argv[1..-1]
|
||||||
|
end
|
||||||
|
end
|
||||||
+17
-16
@@ -4,27 +4,28 @@
|
|||||||
# CATEGORY
|
# CATEGORY
|
||||||
# 12-ai-and-developer-tools
|
# 12-ai-and-developer-tools
|
||||||
#
|
#
|
||||||
|
# DEPENDENCIES
|
||||||
|
# docker
|
||||||
|
#
|
||||||
# SYNOPSIS
|
# SYNOPSIS
|
||||||
# docker [subcommand] [args...]
|
# dops [args...]
|
||||||
#
|
#
|
||||||
# DESCRIPTION
|
# DESCRIPTION
|
||||||
# Wrapper for docker that intercepts the ps subcommand and redirects it to
|
# Enhanced container listing: runs docker ps with a clean custom table
|
||||||
# the dops function for enhanced container listing. All other subcommands are
|
# (Names, Image, Status, Ports) instead of docker's noisier default
|
||||||
# passed through to the real docker binary.
|
# columns. Extra arguments (e.g. -a) are forwarded to docker ps.
|
||||||
#
|
#
|
||||||
# ARGUMENTS
|
# ARGUMENTS
|
||||||
# subcommand Docker subcommand (ps is redirected to dops)
|
# args... Arguments forwarded to `docker ps`
|
||||||
# args... Arguments forwarded to docker or dops
|
#
|
||||||
|
# EXIT STATUS
|
||||||
|
# Exit status of `docker ps`
|
||||||
#
|
#
|
||||||
# EXAMPLE
|
# EXAMPLE
|
||||||
# docker ps
|
# dops
|
||||||
function docker --description 'Execute docker'
|
# dops -a
|
||||||
if test -n "$argv[1]"
|
function dops --description 'Enhanced, formatted docker ps listing'
|
||||||
switch $argv[1]
|
__fish_help_header (status current-function) $argv; and return 0
|
||||||
case ps
|
|
||||||
dops $argv[2..-1]
|
command docker ps --format 'table {{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}' $argv
|
||||||
case '*'
|
|
||||||
command docker $argv[1..-1]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -316,8 +316,9 @@ function test_every_user_facing_function_has_help
|
|||||||
# Published == carries a `# CATEGORY` block, matching
|
# Published == carries a `# CATEGORY` block, matching
|
||||||
# manualtools.parse_functions.
|
# manualtools.parse_functions.
|
||||||
contains -- "# CATEGORY" (string trim -- $lines); or continue
|
contains -- "# CATEGORY" (string trim -- $lines); or continue
|
||||||
# Resolve the real defined name; the file stem can disagree
|
# Resolve the real defined name; the file stem can disagree with it
|
||||||
# (dops.fish defines `docker` -- see JOB-BRIEF-FINDINGS.md §1).
|
# (formerly dops.fish defined `docker` -- see JOB-BRIEF-FINDINGS.md
|
||||||
|
# §1, fixed by splitting it into dops.fish and docker.fish).
|
||||||
set -l name (string match -rg '^\s*function\s+(\S+)' -- $lines)[1]
|
set -l name (string match -rg '^\s*function\s+(\S+)' -- $lines)[1]
|
||||||
test -n "$name"; or continue
|
test -n "$name"; or continue
|
||||||
set name (string trim -c "'\"" -- $name)
|
set name (string trim -c "'\"" -- $name)
|
||||||
|
|||||||
Reference in New Issue
Block a user