Skip to content

Commit

Permalink
Fixed the broken env variables help message.
Browse files Browse the repository at this point in the history
Fixes: #79
  • Loading branch information
matejak committed May 11, 2019
1 parent d37552c commit 4fc0b55
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 11 deletions.
10 changes: 9 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
2.8.0 (2019-01-26)
2.8.1 (TBA)
-----------

Bugfixes:

* The environment variables help message has been fixed (#79).


2.8.0 (2019-01-26)
------------------

New features:

* Allow argbash and argbash-init to be run from symbolic links.
Expand Down
32 changes: 24 additions & 8 deletions src/stuff.m4
Original file line number Diff line number Diff line change
Expand Up @@ -302,16 +302,32 @@ m4_define([_MAKE_HELP_FUNCTION_OPTIONAL_PART], [m4_lists_foreach_optional(
)])])
dnl
dnl $1: list name
dnl $2: name
dnl $3: default
dnl $4: help
m4_define([_MAKE_ENV_HELP_MESSAGE], [m4_do(
[m4_ifnblank([$4], [m4_list_append([$1], m4_do(
[[$2: $4.]],
[m4_ifnblank([$3], [[ (default: '$3')]])],
))])],
)])
dnl
dnl $1: The name of list for help messages
m4_define([_MAKE_ENV_HELP_MESSAGES], [m4_do(
[m4_lists_foreach([ENV_NAMES,ENV_DEFAULTS,ENV_HELPS], [_name,_default,_help],
[_MAKE_ENV_HELP_MESSAGE([$1], _name, _default, _help)])],
)])
m4_define([_MAKE_HELP_FUNCTION_ENVVARS_PART], [m4_do(
[m4_lists_foreach([ENV_NAMES,ENV_DEFAULTS,ENV_HELPS], [_name,_default,_help], [m4_do(
[m4_ifnblank(_help, [m4_list_append([LIST_ENV_HELP], m4_expand([m4_do(
[m4_expand([_name: _help.])],
[m4_ifnblank(_default, [ (default: ']_default'))],
)]))])],
)])],
[printf '\nEnvironment variables that are supported:\n'
[_MAKE_ENV_HELP_MESSAGES([LIST_ENV_HELP])],
[_INDENT_()printf '\nEnvironment variables that are supported:\n'
],
[m4_list_foreach([LIST_ENV_HELP], [_msg], [printf '\t%s\n' "[]_msg"
[m4_list_foreach([LIST_ENV_HELP], [_msg], [_INDENT_()printf '\t%s\n' "[]_msg"
])],
)])
Expand Down
4 changes: 2 additions & 2 deletions start_tmux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ tmux new-session -d -s argbash
tmux send-keys 'cd src' C-m
tmux send-keys 'vim stuff.m4' C-m
tmux new-window -c resources
tmux send-keys -l 'make check'
tmux new-window -c tests/regressiontests
tmux send-keys -l 'make unittests'
tmux new-window -c tests/unittests
tmux send-keys -l 'vim '
tmux select-window -t argbash:0
tmux -2 attach-session -t argbash
19 changes: 19 additions & 0 deletions tests/unittests/check-env.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
m4_include([argbash-lib.m4])
m4_include([test-support.m4])

ARG_USE_ENV([OS_CLOUD], , [my blah help text])
ARG_USE_ENV([BOMB], [default BOMB], [a, BOMB])

assert_equals_list_element([ENV_NAMES], , [OS_CLOUD])
assert_equals_list_next([BOMB])
assert_equals_list_element([ENV_DEFAULTS], [])
assert_equals_list_next([default BOMB])
assert_equals_list_element([ENV_HELPS], , [my blah help text])
assert_equals_list_next([a, BOMB])
assert_equals_list_element([ENV_ARGNAMES], , [])
assert_equals_list_next([])

_MAKE_ENV_HELP_MESSAGES([_MSGS])

assert_equals_list_element([_MSGS], , [OS_CLOUD: my blah help text.])
assert_equals_list_next([BOMB: a, BOMB. (default: 'default BOMB')])

0 comments on commit 4fc0b55

Please sign in to comment.