#!/bin/sh # crudini --help generator for help2man and README.md if [ "$1" = '--help' ]; then { printf '%s' 'crudini - ' python3 crudini.py --help | sed 's/crudini\.py/crudini/g;' echo cat EXAMPLES } elif [ "$1" = '--markdown' ]; then { printf '%s' '# crudini - ' python3 crudini.py --help | sed 's/crudini\.py/crudini/g;' echo cat EXAMPLES } | sed 's/^\([^ ]\+:\)\( \+\)/\1\n/' | # Sections on own line sed 's/^[^ ]\+:/```\n## &\n```/' | # Markup sections sed 's/^ *or: *//' | # Delete help2man synopsis formatting sed '0,/```/{/```/d;}' # Delete first ``` echo '```' # Add terminating ``` elif [ "$1" = '--version' ]; then python3 crudini.py --version fi