Skip to content

Commit b720e21

Browse files
authored
Merge pull request #203 from yeldiRium/usage-basename
Show basename of script in usage text
2 parents 7f752ed + 048bc46 commit b720e21

7 files changed

Lines changed: 9 additions & 4 deletions

File tree

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ Kevin Stravers <kevin@stravers.net>
55
Matěj Týč <matej.tyc@gmail.com>
66
Nicola Lunghi <nick83ola@gmail.com>
77
Stephen Gallagher <sgallagh@redhat.com>
8+
Hannes Leutloff <hannes.leutloff@yeldirium.de>

bin/argbash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ _arg_debug=
8686
print_help()
8787
{
8888
printf '%s\n' "Argbash is an argument parser generator for Bash."
89-
printf 'Usage: %s [-o|--output <arg>] [-i|--(no-)in-place] [-t|--type <type>] [--(no-)library] [--strip <content>] [--(no-)check-typos] [-c|--(no-)commented] [-I|--search <arg>] [--debug <arg>] [-h|--help] [-v|--version] <input>\n' "$0"
89+
printf 'Usage: %s [-o|--output <arg>] [-i|--(no-)in-place] [-t|--type <type>] [--(no-)library] [--strip <content>] [--(no-)check-typos] [-c|--(no-)commented] [-I|--search <arg>] [--debug <arg>] [-h|--help] [-v|--version] <input>\n' "$(basename "$0")"
9090
printf '\t%s\n' "<input>: The input template file (pass '-' for stdin)"
9191
printf '\t%s\n' "-o, --output: Name of the output file (pass '-' for stdout) (default: '-')"
9292
printf '\t%s\n' "-i, --in-place, --no-in-place: Update a bash script in-place (off by default)"

bin/argbash-1to2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ _arg_output=""
4242
print_help()
4343
{
4444
printf '%s\n' "Convert a template for argbash>=1,<2 to argbash>=2,<3"
45-
printf 'Usage: %s [-o|--output <arg>] [-v|--version] [-h|--help] <input-1> [<input-2>] ... [<input-n>] ...\n' "$0"
45+
printf 'Usage: %s [-o|--output <arg>] [-v|--version] [-h|--help] <input-1> [<input-2>] ... [<input-n>] ...\n' "$(basename "$0")"
4646
printf '\t%s\n' "<input>: The input file to transform"
4747
printf '\t%s\n' "-o, --output: Name of the output file (pass '-' for stdout and empty string for the same as input file) (default: '""')"
4848
printf '\t%s\n' "-v, --version: Prints version"

bin/argbash-init

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ _arg_mode="default"
6666
print_help()
6767
{
6868
printf '%s\n' "Make a template for scripts."
69-
printf 'Usage: %s [-s|--separate] [--(no-)hints] [--pos <arg>] [--opt <arg>] [--opt-bool <arg>] [-m|--mode <MODE>] [-v|--version] [-h|--help] [<output>]\n' "$0"
69+
printf 'Usage: %s [-s|--separate] [--(no-)hints] [--pos <arg>] [--opt <arg>] [--opt-bool <arg>] [-m|--mode <MODE>] [-v|--version] [-h|--help] [<output>]\n' "$(basename "$0")"
7070
printf '\t%s\n' "<output>: Name of the output template (default: '-')"
7171
printf '\t%s\n' "-s, --separate: Separate the parsing logic (specify two times for complete separation)"
7272
printf '\t%s\n' "--hints, --no-hints: Whether to write hints to the script template (off by default)"

src/stuff.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ m4_define([_MAKE_HELP], [MAKE_FUNCTION(
417417
[dnl If we have optionals, display them like [--opt1 arg] [--(no-)opt2] ... according to their type. @<:@ becomes square bracket at the end of processing
418418
],
419419
[_MAKE_HELP_SYNOPSIS([$1])],
420-
[\n' "@S|@0"_ENDL_()],
420+
[\n' "$(basename "@S|@0")"_ENDL_()],
421421
[_IF_HAVE_POSITIONAL_ARGS([_MAKE_HELP_FUNCTION_POSITIONAL_PART])],
422422
[dnl If we have 0 optional args, don't do anything (FOR loop would assert, 0 < 1)
423423
],

tests/regressiontests/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ basic: $(TESTDIR)/basic.sh
266266
grep -q "local _key$$" $<
267267
$< -h | grep -q 'P percent: %'
268268
$< -h | grep -q 'O percent: %'
269+
$< -h | grep -q 'Usage: $(notdir $<) '
269270
! $< -h | grep -qe '\[--\]'
270271
test -z "$(SHELLCHECK)" || $(SHELLCHECK) "$(TESTDIR)/basic.sh"
271272
basic-dash: $(TESTDIR)/basic-dash.sh
@@ -275,6 +276,7 @@ basic-dash: $(TESTDIR)/basic-dash.sh
275276
$< LOO -b | grep -q BOOL=off,
276277
$< -h | grep -q 'P percent: %'
277278
$< -h | grep -q 'O percent: %'
279+
$< -h | grep -q 'Usage: $(notdir $<) '
278280
$< -h | grep -qe '\[--\]'
279281
test -z "$(SHELLCHECK)" || $(SHELLCHECK) "$(TESTDIR)/basic-dash.sh"
280282
test-void: $(TESTDIR)/test-void.sh

tests/regressiontests/make/tests/tests-base.m4

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ ADD_TEST_BASH([basic], [[
99
grep -q "local _key$$" $<
1010
$< -h | grep -q 'P percent: %'
1111
$< -h | grep -q 'O percent: %'
12+
$< -h | grep -q 'Usage: $(notdir $<) '
1213
! $< -h | grep -qe '\[--\]'
1314
]])
1415

@@ -20,6 +21,7 @@ ADD_TEST_DASH([basic], [[
2021
$< LOO -b | grep -q BOOL=off,
2122
$< -h | grep -q 'P percent: %'
2223
$< -h | grep -q 'O percent: %'
24+
$< -h | grep -q 'Usage: $(notdir $<) '
2325
$< -h | grep -qe '\[--\]'
2426
]])
2527

0 commit comments

Comments
 (0)