diff --git a/dev/tools.sh b/dev/tools.sh index e9aee64..81631ef 100755 --- a/dev/tools.sh +++ b/dev/tools.sh @@ -1,16 +1,54 @@ -#!/bin/bash +#!/usr/bin/env bash +# +# Run Python code tools (isort, black, flake8) +# #### SETUP #################################################################### + +set -o errexit set -o errtrace set -o nounset -printf "\e[1m\e[7m %-80s\e[0m\n" 'isort' +# shellcheck disable=SC2154 +trap '_es=${?}; + printf "${0}: line ${LINENO}: \"${BASH_COMMAND}\""; + printf " exited with a status of ${_es}\n"; + exit ${_es}' ERR + +DIR_REPO="$(cd -P -- "${0%/*}/.." && pwd -P)" +# https://en.wikipedia.org/wiki/ANSI_escape_code +E0="$(printf "\e[0m")" # reset +E30="$(printf "\e[30m")" # black foreground +E31="$(printf "\e[31m")" # red foreground +E107="$(printf "\e[107m")" # bright white background + +#### FUNCTIONS ################################################################ + +error_exit() { + # Echo error message and exit with error + echo -e "${E31}ERROR:${E0} ${*}" 1>&2 + exit 1 +} + +print_header() { + # Print 80 character wide black on white heading with time + printf "${E30}${E107}# %-69s$(date '+%T') ${E0}\n" "${@}" +} + +#### MAIN ##################################################################### + +cd "${DIR_REPO}" + +print_header 'isort' +# shellcheck disable=SC2068 pipenv run isort ${@:-.} echo -printf "\e[1m\e[7m %-80s\e[0m\n" 'black' +print_header 'black' +# shellcheck disable=SC2068 pipenv run black ${@:-.} echo -printf "\e[1m\e[7m %-80s\e[0m\n" 'flake8' +print_header 'flake8' +# shellcheck disable=SC2068 pipenv run flake8 ${@:-.} echo diff --git a/enable_workflows.py b/enable_workflows.py index ab30e87..837e51f 100755 --- a/enable_workflows.py +++ b/enable_workflows.py @@ -50,6 +50,8 @@ def setup(): args.dryrun = "" if not args.repos: raise ap.error("at least one (1) REPOSITORY must be specified") + for i, repo in enumerate(args.repos): + args.repos[i] = repo.strip() return args