| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
# crudini --help generator for help2man and README.md |
| 4 |
|
| 5 |
if [ "$1" = '--help' ]; then |
| 6 |
{ |
| 7 |
printf '%s' 'crudini - ' |
| •8 |
python3 crudini.py --help | sed 's/crudini\.py/crudini/g;' |
| 9 |
echo |
| 10 |
cat EXAMPLES |
| 11 |
} |
| 12 |
elif [ "$1" = '--markdown' ]; then |
| 13 |
{ |
| 14 |
printf '%s' '# crudini - ' |
| •15 |
python3 crudini.py --help | sed 's/crudini\.py/crudini/g;' |
| 16 |
echo |
| 17 |
cat EXAMPLES |
| 18 |
} | |
| 19 |
sed 's/^\([^ ]\+:\)\( \+\)/\1\n/' | # Sections on own line |
| 20 |
sed 's/^[^ ]\+:/```\n## &\n```/' | # Markup sections |
| 21 |
sed 's/^ *or: *//' | # Delete help2man synopsis formatting |
| 22 |
sed '0,/```/{/```/d;}' # Delete first ``` |
| 23 |
echo '```' # Add terminating ``` |
| 24 |
elif [ "$1" = '--version' ]; then |
| •25 |
python3 crudini.py --version |
| 26 |
fi |
| 27 |
|