Skip to content

Instantly share code, notes, and snippets.

@lnquy
Forked from kovetskiy/samizdat-shell-help.bash
Created July 9, 2020 09:15
Show Gist options
  • Save lnquy/8ff5009141cee92dbde1cbf7dc68bc4a to your computer and use it in GitHub Desktop.
Save lnquy/8ff5009141cee92dbde1cbf7dc68bc4a to your computer and use it in GitHub Desktop.

Revisions

  1. @kovetskiy kovetskiy created this gist Jul 7, 2020.
    22 changes: 22 additions & 0 deletions samizdat-shell-help.bash
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    #!/bin/bash
    ###
    ### my-script — does one thing well
    ###
    ### Usage:
    ### my-script <input> <output>
    ###
    ### Options:
    ### <input> Input file to read.
    ### <output> Output file to write. Use '-' for stdout.
    ### -h Show this message.

    help() {
    sed -rn 's/^### ?//;T;p' "$0"
    }

    if [[ $# == 0 ]] || [[ "$1" == "-h" ]]; then
    help
    exit 1
    fi

    echo Hello World