pashage

Yet Another Opinionated Re-engineering of the Unix Password Store
git clone https://git.instinctive.eu/pashage.git
Log | Files | Refs | README | LICENSE

commit 25805f0bbcd8f1658bc60c837e31432ed76cba58
parent d636dc7d8fdd54ce6a2ef7844a76bbbcff7d36f4
Author: Natasha Kerensikova <natgh@instinctive.eu>
Date:   Mon,  1 Dec 2025 18:39:50 +0000

Help subcommand accepts subcommand arguments
Diffstat:
MREADME.md | 10+++++++---
Mpashage.1 | 9+++++++--
Mspec/pashage_extra_spec.sh | 15+++++++++++++++
Mspec/usage_spec.sh | 39++++++++++++++++++++++++++++++---------
Msrc/pashage.sh | 11+++++++----
Msrc/run.sh | 6+++---
6 files changed, 69 insertions(+), 21 deletions(-)

diff --git a/README.md b/README.md @@ -443,11 +443,15 @@ Environment: Syntax: ``` -pashage help +pashage help [subcommand ...] ``` -This subcommand displays on the standard output the version and help text, -including all subcommands and flags and a brief description. +This subcommand displays on the standard output the help text for the +given subcommands. + +Without arguments, this subcommand displays on the standard output the +version and help text, including all subcommands and flags and a brief +description. This subcommand is not affected by the environment. diff --git a/pashage.1 b/pashage.1 @@ -184,9 +184,14 @@ corresponding secret. .Ss help .Nm .Cm help +.Op Ar subcommand ... .Pp -This subcommand displays on the standard output the version and help text, -including all subcommands and flags and a brief description. +This subcommand displays on the standard output the help text for the +given subcommands. +.Pp +Without arguments, this subcommand displays on the standard output the +version and help text, including all subcommands and flags and a brief +description. .Ss init .Nm .Cm init diff --git a/spec/pashage_extra_spec.sh b/spec/pashage_extra_spec.sh @@ -970,6 +970,21 @@ Describe 'Integrated Command Functions' The output should include ' prg random ' The output should include ' prg reencrypt ' End + + It 'displays help text for specific commands with help text' + PROGRAM=prg + When call cmd_help git move + The status should be success + The output should not include 'prg copy ' + The output should not include 'prg delete ' + The output should include 'prg git' + The output should include ' git repository,' + The output should not include 'prg gitconfig' + The output should include 'prg move ' + The output should include 'Renames or moves' + The output should not include 'prg random ' + The output should not include 'prg reencrypt ' + End End Describe 'cmd_init' diff --git a/spec/usage_spec.sh b/spec/usage_spec.sh @@ -1212,9 +1212,13 @@ Describe 'Command-Line Parsing' Describe 'cmd_help' COMMAND=help - It 'displays version and usage' + It 'displays version and usage without arguments' cmd_usage() { mocklog cmd_usage "$@"; } cmd_version() { mocklog cmd_version "$@"; } + expected_output() { %text + #| + #|Usage: + } result() { %text | @sed 's/\$$//' #|$ cmd_version @@ -1222,9 +1226,18 @@ Describe 'Command-Line Parsing' } When call cmd_help The status should be success - The output should be blank + The output should equal "$(expected_output)" The error should equal "$(result)" End + + It 'displays only usage with arguments' + cmd_usage() { mocklog cmd_usage "$@"; } + cmd_version() { mocklog cmd_version "$@"; } + When call cmd_help foo bar + The status should be success + The output should be blank + The error should equal '$ cmd_usage yes foo bar' + End End Describe 'cmd_init' @@ -2378,13 +2391,6 @@ Describe 'Command-Line Parsing' GENERATED_LENGTH='$GENERATED_LENGTH' cat() { @cat; } - It 'displays a human-reable usage string' - When call cmd_usage - The status should be success - The first line of output should equal 'Usage:' - The error should be blank - End - It 'includes help about all commands' When call cmd_usage The status should be success @@ -2407,6 +2413,21 @@ Describe 'Command-Line Parsing' The output should include 'prg version' End + It 'displays terse help about the given commands' + When call cmd_usage no '> ' version edit version + The status should be success + The output should match pattern '*prg version*prg edit*prg version*' + The lines of output should equal 3 + End + + It 'displays verbose help about the given commands' + When call cmd_usage yes '> ' version edit version + The status should be success + The output should match pattern \ + '*prg version*Show*prg edit*Insert*prg version*Show*' + The lines of output should equal 6 + End + It 'rejects unknown commands' When run cmd_usage no '> ' foo The output should be blank diff --git a/src/pashage.sh b/src/pashage.sh @@ -1459,9 +1459,13 @@ cmd_gitconfig() { } cmd_help() { - cmd_version - printf '\n' - cmd_usage yes ' ' + if [ $# -eq 0 ]; then + cmd_version + printf '\nUsage:\n' + cmd_usage yes ' ' "$@" + else + cmd_usage yes '' "$@" + fi } cmd_init() { @@ -1765,7 +1769,6 @@ cmd_usage(){ fi if [ $# -eq 0 ]; then - echo 'Usage:' set -- list show copy delete edit find generate git gitconfig \ grep help init insert move random reencrypt version fi diff --git a/src/run.sh b/src/run.sh @@ -106,9 +106,9 @@ case "${COMMAND}" in git) shift; cmd_git "$@" ;; gitconfig) shift; cmd_gitconfig ;; grep) shift; cmd_grep "$@" ;; - help) shift; cmd_help ;; - -h) shift; cmd_help ;; - --help) shift; cmd_help ;; + help) shift; cmd_help "$@" ;; + -h) shift; cmd_help "$@" ;; + --help) shift; cmd_help "$@" ;; init) shift; cmd_init "$@" ;; insert) shift; cmd_insert "$@" ;; list) shift; cmd_list_or_show "$@" ;;