Skip to content
This repository was archived by the owner on Jun 17, 2022. It is now read-only.

Commit

Permalink
refactor: rename 'command' to 'task' and 'common' to 'util'
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperupcall committed Jun 13, 2021
1 parent 4193b0c commit 2c0c29e
Show file tree
Hide file tree
Showing 32 changed files with 50 additions and 50 deletions.
10 changes: 5 additions & 5 deletions bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# shellcheck shell=bash

# The following is eval'ed as 'eval "$GLUE_BOOTSTRAP"'
# in either '{commands,actions}/{,auto/}*'
# in either '{tasks,actions}/{,auto/}*'

# Check if we have already bootstraped. This is useful for multiple sources of files
if [ ! "$GLUE_BOOTSTRAP_DID" = yes ]; then
Expand All @@ -14,10 +14,10 @@ if [ ! "$GLUE_BOOTSTRAP_DID" = yes ]; then
exit 1
fi

if [ -f "$GLUE_WD/.glue/common/bootstrap.sh" ]; then
source "$GLUE_WD/.glue/common/bootstrap.sh"
elif [ -f "$GLUE_WD/.glue/common/auto/bootstrap.sh" ]; then
source "$GLUE_WD/.glue/common/auto/bootstrap.sh"
if [ -f "$GLUE_WD/.glue/util/bootstrap.sh" ]; then
source "$GLUE_WD/.glue/util/bootstrap.sh"
elif [ -f "$GLUE_WD/.glue/util/auto/bootstrap.sh" ]; then
source "$GLUE_WD/.glue/util/auto/bootstrap.sh"
else
echo "Context \$0: '$0'" >&2
echo "Context \${BASH_SOURCE[*]}: ${BASH_SOURCE[*]}" >&2
Expand Down
25 changes: 0 additions & 25 deletions common/command.sh

This file was deleted.

2 changes: 1 addition & 1 deletion docs/task-steps.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# General Steps for Tasks

Common task identifiers like 'build', 'docs', 'lint' are common across languages. This document lists them with some explanations. Depending on the project type, some commands may accept flags. For example, use `glue cmd docs -- --help` to show the help, if applicable
Common task identifiers like 'build', 'docs', 'lint' are common across languages. This document lists them with some explanations. Depending on the project type, some tasks may accept flags. For example, use `glue cmd docs -- --help` to show the help, if applicable

## docs

Expand Down
2 changes: 1 addition & 1 deletion commands/Bash.build.sh → tasks/Bash.build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ task() {
source "$REPLY"

# With 'set -e' enabled, the previous commands
# were successfull; otherwise, we wouldn't be here
# were successful; otherwise, we wouldn't be here
REPLY=0
}

Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions commands/Bash.release.sh → tasks/Bash.release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@ task() {

## 2
# Build docs
util.get_command 'Bash.docs.sh'
util.get_task 'Bash.docs.sh'
source "$REPLY"
ensure.exit_code_success "$REPLY"

# Lint
util.get_command 'Bash.lint.sh'
util.get_task 'Bash.lint.sh'
source "$REPLY"
ensure.exit_code_success "$REPLY"

# Build
util.get_command 'Bash.build.sh'
util.get_task 'Bash.build.sh'
source "$REPLY"
ensure.exit_code_success "$REPLY"

# Test
util.get_command 'Bash.test.sh'
util.get_task 'Bash.test.sh'
source "$REPLY"
ensure.exit_code_success "$REPLY"

Expand Down
2 changes: 1 addition & 1 deletion commands/Bash.run.sh → tasks/Bash.run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ task() {
ensure.nonZero 'cmdName' "$cmdName"
shift

util.get_command 'Bash.build.sh'
util.get_task 'Bash.build.sh'
source "$REPLY"

local -a args=()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions common/action.sh → util/action.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env bash

# @description Print the currently running command
# @description Print the currently running action
# @noargs
# @see command.log
# @see task.log
action.log() {
# ${BASH_SOURCE[0]}: Ex. ~/.../.glue/actions/auto/util/action.sh
# ${BASH_SOURCE[1]}: Ex. ~/.../.glue/actions/auto/util/bootstrap.sh
Expand Down
14 changes: 7 additions & 7 deletions common/bootstrap.sh → util/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ bootstrap() {
cd "$_original_wd"
}

# source files in 'common'
local dir="common"
# source files in 'util'
local dir="util"

shopt -q nullglob
local shoptExitStatus="$?"
Expand Down Expand Up @@ -84,8 +84,8 @@ bootstrap() {
actions)
action.log
;;
commands)
command.log
tasks)
task.log
;;
*)
die "boostrap: Directory '$dir' not supported"
Expand Down Expand Up @@ -121,11 +121,11 @@ unbootstrap() {

# Print
case "$dir" in
commands)
tasks)
if [[ "${LANG,,?}" == *utf?(-)8 ]]; then
echo "■■ 🢀 END COMMAND"
echo "■■ 🢀 END TASK"
else
echo ":: <= END COMMAND"
echo ":: <= END TASK"
fi

;;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 25 additions & 0 deletions util/task.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

# @description Log the currently running task
# @noargs
# @see action.log
task.log() {
# Path to the currently actually executing 'action' script
# This works on the assumption that 'source's are all absolute paths
local currentTask="${BASH_SOURCE[2]}"
local currentTaskDirname="${currentTask%/*}"

if [ "${currentTaskDirname##*/}" = auto ]; then
if [[ "${LANG,,?}" == *utf?(-)8 ]]; then
echo "■■ 🢂 START TASK: 'auto/${currentTask##*/}'"
else
echo ":: => START TASK: 'auto/${currentTask##*/}'"
fi
else
if [[ "${LANG,,?}" == *utf?(-)8 ]]; then
echo "■■ 🢂 START TASK: '${currentTask##*/}'"
else
echo ":: => START TASK: '${currentTask##*/}'"
fi
fi
}
File renamed without changes.
8 changes: 4 additions & 4 deletions common/util.sh → util/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ util.get_action() {
fi
}

# Get any particular file in the 'commands' directory
# Get any particular file in the 'tasks' directory
# Pass '-q' as the first arg to set the result to
# '$REPLY' rather than outputing to standard output
util.get_command() {
util.get_task() {
if [ "$1" = "-p" ]; then
util.get_file "commands" "$2"
util.get_file "tasks" "$2"
printf "%s\n" "$REPLY"
else
util.get_file "commands" "$1"
util.get_file "tasks" "$1"
fi
}

Expand Down

0 comments on commit 2c0c29e

Please sign in to comment.