mbland / go-script-bash

Framework for writing modular, discoverable, testable Bash scripts
ISC License
95 stars 16 forks source link

Uses a help tokens array to replace tokens in help text #255

Open nkakouros opened 4 years ago

nkakouros commented 4 years ago

cc: @mbland

The --help-filter option and the # Help filter comment is too much for the user for sth that they may need to implement in every command script they write. Also, it limits a bit some use cases, for instance using docopts together with go-script-bash.

This PR adds a new associative array _GO_HELP_TOKENS. Each item in the array is a token=>replacement pair and go-script-bash automatically performs any replacements when generating the help text. This is complementary to the --help-filter method, which is compatible with old bash versions.

coveralls commented 4 years ago

Coverage Status

Coverage increased (+0.03%) to 95.031% when pulling b34c9d4b5edbd8442ba895bb892dc897eb54cba9 on nkakouros-forks:help-tokens into 292e0803074eb538ab8633a657c53d3a975ba922 on mbland:master.