Less verbose header comments

This commit is contained in:
Kevin van Zonneveld 2016-06-21 13:48:08 +02:00
parent 4926bbc942
commit 008face7c8
8 changed files with 71 additions and 91 deletions

View File

@ -4,6 +4,7 @@
Released: Unreleased. [Commit log](https://github.com/kvz/bash3boilerplate/compare/v2.0.0...master)
- Less verbose header comments
- For delete-key-friendliness, don't crash on undeclared help vars
- Introduce `errtrace`, which is on by default (BREAKING)
- Add a configurable `helptext` that is left alone by the parses and allows you to have a richer help

32
main.sh
View File

@ -1,37 +1,15 @@
#!/usr/bin/env bash
# BASH3 Boilerplate
#
# This file:
#
# - Is a template to write better bash scripts
# - Is delete-key friendly, in case you don't need e.g. command line option parsing
#
# More info:
#
# - https://github.com/kvz/bash3boilerplate
# - http://kvz.io/blog/2013/02/26/introducing-bash3boilerplate/
#
# Version: 2.0.0
#
# Authors:
#
# - [Kevin van Zonneveld](http://kvz.io)
# - [Izaak Beekman](https://izaakbeekman.com/)
# - [Alexander Rathai](mailto:<Alexander.Rathai@gmail.com>)
# - [Dr. Damian Rouson](http://www.sourceryinstitute.org/) (documentation)
# - Demos BASH3 Boilerplate (change this for your script)
#
# Usage:
#
# LOG_LEVEL=7 ./main.sh -f /tmp/x -d
# LOG_LEVEL=7 ./main.sh -f /tmp/x -d (change this for your script)
#
# Copyright (c) 2013 Kevin van Zonneveld (http://kvz.io) and contributors
# Licensed under MIT: https://raw.githubusercontent.com/kvz/bash3boilerplate/master/LICENSE
# You are not obligated to ship the license file with your b3bp projects as long
# as you leave the above comments intact.
### Configuration
#####################################################################
# Based on a template by BASH3 Boilerplate v2.0.0
# Copyright (c) 2013 Kevin van Zonneveld and contributors
# http://bash3boilerplate.sh/#authors
# Exit on error. Append ||true if you expect an error.
# `set` is safer than relying on a shebang like `#!/bin/bash -e` because that is neutralized

View File

@ -9,17 +9,6 @@
#
# - All keys inside the .ini file must be unique, regardless of the use of sections
#
# More info:
#
# - https://github.com/kvz/bash3boilerplate
# - http://kvz.io/blog/2013/02/26/introducing-bash3boilerplate/
#
# Version: 2.0.0
#
# Authors:
#
# - Kevin van Zonneveld (http://kvz.io)
#
# Usage as a function:
#
# source ini_val.sh
@ -29,10 +18,9 @@
#
# ini_val.sh data.ini connection.host 127.0.0.1
#
# Copyright (c) 2013 Kevin van Zonneveld and [contributors](https://github.com/kvz/bash3boilerplate#authors)
# Licensed under [MIT](https://raw.githubusercontent.com/kvz/bash3boilerplate/master/LICENSE)
# You are not obligated to bundle the LICENSE file with your b3bp projects as long
# as you leave these references intact.
# Based on a template by BASH3 Boilerplate v2.0.0
# Copyright (c) 2013 Kevin van Zonneveld and contributors
# http://bash3boilerplate.sh/#authors
function ini_val() {
local file="${1:-}"

View File

@ -11,17 +11,6 @@
#
# - ./parse_url.sh
#
# More info:
#
# - https://github.com/kvz/bash3boilerplate
# - http://kvz.io/blog/2013/02/26/introducing-bash3boilerplate/
#
# Version: 2.0.0
#
# Authors:
#
# - Kevin van Zonneveld (http://kvz.io)
#
# Usage as a function:
#
# source megamount.sh
@ -31,10 +20,9 @@
#
# megamount.sh smb://janedoe:abc123@192.168.0.1/documents /mnt/documents
#
# Copyright (c) 2013 Kevin van Zonneveld and [contributors](https://github.com/kvz/bash3boilerplate#authors)
# Licensed under [MIT](https://raw.githubusercontent.com/kvz/bash3boilerplate/master/LICENSE)
# You are not obligated to bundle the LICENSE file with your b3bp projects as long
# as you leave these references intact.
# Based on a template by BASH3 Boilerplate v2.0.0
# Copyright (c) 2013 Kevin van Zonneveld and contributors
# http://bash3boilerplate.sh/#authors
__dir=$(cd `dirname "${BASH_SOURCE[0]}"` && pwd)
source "${__dir}/parse_url.sh"

View File

@ -5,20 +5,10 @@
#
# - Takes a URL and parses protocol, user, pass, host, port, path.
#
# More info:
#
# - https://github.com/kvz/bash3boilerplate
#
# Based on:
#
# - http://stackoverflow.com/a/6174447/151666
#
# Version: 2.0.0
#
# Authors:
#
# - Kevin van Zonneveld (http://kvz.io)
#
# Usage as a function:
#
# source parse_url.sh
@ -28,10 +18,9 @@
#
# parse_url.sh 'http://johndoe:abc123@example.com:8080/index.html'
#
# Copyright (c) 2013 Kevin van Zonneveld and [contributors](https://github.com/kvz/bash3boilerplate#authors)
# Licensed under [MIT](https://raw.githubusercontent.com/kvz/bash3boilerplate/master/LICENSE)
# You are not obligated to bundle the LICENSE file with your b3bp projects as long
# as you leave these references intact.
# Based on a template by BASH3 Boilerplate v2.0.0
# Copyright (c) 2013 Kevin van Zonneveld and contributors
# http://bash3boilerplate.sh/#authors
function parse_url() {
local parse="${1}"

View File

@ -6,17 +6,6 @@
# - takes a source (template) & destination (config) filepath argument
# - then replaces placeholders with variables found in the environment
#
# More info:
#
# - https://github.com/kvz/bash3boilerplate
# - http://kvz.io/blog/2013/02/26/introducing-bash3boilerplate/
#
# Version: 2.0.0
#
# Authors:
#
# - Kevin van Zonneveld (http://kvz.io)
#
# Usage as a function:
#
# source templater.sh
@ -27,10 +16,9 @@
#
# ALLOW_REMAINDERS=1 templater.sh input.cfg output.cfg
#
# Copyright (c) 2013 Kevin van Zonneveld and [contributors](https://github.com/kvz/bash3boilerplate#authors)
# Licensed under [MIT](https://raw.githubusercontent.com/kvz/bash3boilerplate/master/LICENSE)
# You are not obligated to bundle the LICENSE file with your b3bp projects as long
# as you leave these references intact.
# Based on a template by BASH3 Boilerplate v2.0.0
# Copyright (c) 2013 Kevin van Zonneveld and contributors
# http://bash3boilerplate.sh/#authors
function templater() {
ALLOW_REMAINDERS="${ALLOW_REMAINDERS:-0}"

View File

@ -1,13 +1,38 @@
#!/usr/bin/env bash
set -o pipefail
# This file:
#
# - Let's inject.sh inject markdown files into the ./website directory
# - Syncs that to a temporary directory along with a git init
# - (in case of Travis CI) assumes a Git bot identity, and uses an overriden GHPAGES_URL containing its token thanks to `travis encrypt`
# - Force pushes that to the gh-pages branch
#
# Usage:
#
# ./deploy.sh
#
# Based on a template by BASH3 Boilerplate v2.0.0
# Copyright (c) 2013 Kevin van Zonneveld and contributors
# http://bash3boilerplate.sh/#authors
# Exit on error. Append || true if you expect an error.
set -o errexit
# Exit on error inside any functions or subshells.
set -o errtrace
# Do not allow use of undefined vars. Use ${VAR:-} to use an undefined VAR
set -o nounset
# Catch the error in case mysqldump fails (but gzip succeeds) in `mysqldump |gzip`
set -o pipefail
# Turn on traces, useful while debugging but commented out by default
# set -o xtrace
# Set magic variables for current file & dir
# Set magic variables for current file, directory, os, etc.
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
__file="${__dir}/$(basename "${BASH_SOURCE[0]}")"
__base="$(basename ${__file} .sh)"
__os="Linux"
if [[ "${OSTYPE:-}" == "darwin"* ]]; then
__os="OSX"
fi
ghpages_repo=${GHPAGES_REPO:-"kvz/bash3boilerplate"}
ghpages_branch=${GHPAGES_BRANCH:-"gh-pages"}

View File

@ -1,14 +1,37 @@
#!/usr/bin/env bash
set -o pipefail
# This file:
#
# - Injects markdown files into the ./website directory
# - Changes them a little to make them more suitable for Jekyll building
#
# Usage:
#
# ./inject.sh
#
# Based on a template by BASH3 Boilerplate v2.0.0
# Copyright (c) 2013 Kevin van Zonneveld and contributors
# http://bash3boilerplate.sh/#authors
# Exit on error. Append || true if you expect an error.
set -o errexit
# Exit on error inside any functions or subshells.
set -o errtrace
# Do not allow use of undefined vars. Use ${VAR:-} to use an undefined VAR
set -o nounset
# Catch the error in case mysqldump fails (but gzip succeeds) in `mysqldump |gzip`
set -o pipefail
# Turn on traces, useful while debugging but commented out by default
# set -o xtrace
# Set magic variables for current file & dir
# Set magic variables for current file, directory, os, etc.
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
__file="${__dir}/$(basename "${BASH_SOURCE[0]}")"
__base="$(basename ${__file} .sh)"
__webroot="$(cd "$(dirname "${__dir}")" && pwd)"
__os="Linux"
if [[ "${OSTYPE:-}" == "darwin"* ]]; then
__os="OSX"
fi
for doc in "README" "FAQ" "CHANGELOG"; do
targetName="$(echo "${doc}" | awk '{print tolower($0)}')"