mirror of
https://github.com/kennethreitz/bake.git
synced 2026-06-05 23:00:17 +00:00
improvements
This commit is contained in:
@@ -61,8 +61,8 @@ ci/setup: @skip:key=Pipfile.lock
|
||||
|
||||
random/python:
|
||||
#!/usr/bin/env python
|
||||
import site
|
||||
print(site)
|
||||
import requests
|
||||
print(requests)
|
||||
|
||||
|
||||
|
||||
|
||||
+10
-18
@@ -223,27 +223,19 @@ class Bakefile:
|
||||
"""The source of the 'root level' of the Bashfile."""
|
||||
return "\n".join(list(self.iter_root_source_lines))
|
||||
|
||||
def iter_funcs_source(self):
|
||||
"""The standard library."""
|
||||
p = os.path.join(os.path.dirname(__file__), "scripts", "stdlib.sh")
|
||||
with open(p, "r") as f:
|
||||
for i, line in enumerate(f.readlines()):
|
||||
# Skip the shebang.
|
||||
if i != 1:
|
||||
yield line
|
||||
|
||||
@property
|
||||
def funcs_source(self):
|
||||
"""Functions (_task_name), inserted into the Bash runtime."""
|
||||
source = []
|
||||
|
||||
# TODO: Recommend bake taskname instead.
|
||||
# for task in self.tasks:
|
||||
# task = self[task]
|
||||
# f_name = task.name.replace("/", "_")
|
||||
# f_name = f_name.replace("-", "_")
|
||||
# f_name = f"task_{f_name}"
|
||||
|
||||
# source.append(
|
||||
# # Replace / namespacing with _ namespacing, for functions.
|
||||
# f"{f_name}()"
|
||||
# + " { \n"
|
||||
# + f" bake --silent {task.name} $@;\n"
|
||||
# + "}\n"
|
||||
# + f"declare -x {f_name};"
|
||||
# )
|
||||
|
||||
source = list(self.iter_funcs_source())
|
||||
return "\n".join(source)
|
||||
|
||||
|
||||
|
||||
+2
-20
@@ -11,21 +11,7 @@ import pygments
|
||||
import pygments.lexers
|
||||
import pygments.formatters
|
||||
|
||||
SKIP_NEXT = False
|
||||
SAFE_ENVIRONS = [
|
||||
"HOME",
|
||||
"PATH",
|
||||
"LANG",
|
||||
"LOCALE",
|
||||
"LANGUAGE",
|
||||
"USER",
|
||||
"TERM",
|
||||
"VIRTUAL_ENV",
|
||||
"BAKEFILE_PATH",
|
||||
"PYTHONUNBUFFERED",
|
||||
"PYTHONDONTWRITEBYTECODE",
|
||||
"BAKE_SILENT",
|
||||
]
|
||||
from .constants import SKIP_NEXT, SAFE_ENVIRONS
|
||||
|
||||
|
||||
def indent(line):
|
||||
@@ -118,9 +104,6 @@ def echo_json(obj):
|
||||
@click.option(
|
||||
"--help", "-h", default=False, is_flag=True, help="Show this message and exit."
|
||||
)
|
||||
@click.option(
|
||||
"--skip-done", default=False, is_flag=True, hidden=True, envvar="BAKE_SKIP_DONE"
|
||||
)
|
||||
@click.option("--debug", default=False, is_flag=True, hidden=True)
|
||||
@click.option("--source", default=False, nargs=1, hidden=True)
|
||||
@click.option(
|
||||
@@ -201,7 +184,6 @@ def entrypoint(
|
||||
insecure,
|
||||
allow,
|
||||
_json,
|
||||
skip_done,
|
||||
no_deps,
|
||||
interactive,
|
||||
yes,
|
||||
@@ -423,7 +405,7 @@ def entrypoint(
|
||||
for task in tasks:
|
||||
execute_task(task, silent=silent)
|
||||
|
||||
if not silent and not skip_done:
|
||||
if not silent:
|
||||
click.echo(
|
||||
click.style(" + ", fg="white")
|
||||
+ click.style("Done", fg="green")
|
||||
|
||||
@@ -1 +1,16 @@
|
||||
INDENT_STYLES = ("\t", " " * 4)
|
||||
SKIP_NEXT = False
|
||||
SAFE_ENVIRONS = [
|
||||
"HOME",
|
||||
"PATH",
|
||||
"LANG",
|
||||
"LOCALE",
|
||||
"LANGUAGE",
|
||||
"USER",
|
||||
"TERM",
|
||||
"VIRTUAL_ENV",
|
||||
"BAKEFILE_PATH",
|
||||
"PYTHONUNBUFFERED",
|
||||
"PYTHONDONTWRITEBYTECODE",
|
||||
"BAKE_SILENT",
|
||||
]
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# ----------
|
||||
# - Colors -
|
||||
# ----------
|
||||
|
||||
function bake_fg_color {
|
||||
BLACK="\033[0;30m"
|
||||
BLACK_BOLD="\033[1;30m"
|
||||
WHITE="\033[0;37m"
|
||||
WHITE_BOLD="\033[1;37m"
|
||||
RED="\033[0;31m"
|
||||
RED_BOLD="\033[1;31m"
|
||||
GREEN="\033[0;32m"
|
||||
GREEN_BOLD="\033[1;32m"
|
||||
YELLOW="\033[0;33m"
|
||||
YELLOW_BOLD="\033[1;33m"
|
||||
BLUE="\033[0;34m"
|
||||
BLUE_BOLD="\033[1;34m"
|
||||
PURPLE="\033[0;35m"
|
||||
PURPLE_BOLD="\033[1;35m"
|
||||
CYAN="\033[0;36m"
|
||||
CYAN_BOLD="\033[1;36m"
|
||||
NO_COLOR="\033[0m"
|
||||
|
||||
CHOSEN_COLOR="${1}"
|
||||
ARGV_INPUT="${2}"
|
||||
|
||||
COLOR="${!CHOSEN_COLOR}"
|
||||
|
||||
if [ -z "$ARGV_INPUT" ]; then
|
||||
read -r INPUT
|
||||
else
|
||||
INPUT="$ARGV_INPUT"
|
||||
fi
|
||||
echo -e "${COLOR}${INPUT}${NO_COLOR}"
|
||||
}
|
||||
|
||||
function bake_black {
|
||||
bake_fg_color 'BLACK' "$1"
|
||||
}
|
||||
|
||||
function bake_white {
|
||||
bake_fg_color 'WHITE' "$1"
|
||||
}
|
||||
|
||||
function bake_red {
|
||||
bake_fg_color 'RED' "$1"
|
||||
}
|
||||
|
||||
function bake_green {
|
||||
bake_fg_color 'GREEN' "$1"
|
||||
}
|
||||
|
||||
function bake_yellow {
|
||||
bake_fg_color 'YELLOW' "$1"
|
||||
}
|
||||
|
||||
function bake_blue {
|
||||
bake_fg_color 'BLUE' "$1"
|
||||
}
|
||||
|
||||
function bake_purple {
|
||||
bake_fg_color 'PURPLE' "$1"
|
||||
}
|
||||
|
||||
function bake_cyan {
|
||||
bake_fg_color 'CYAN' "$1"
|
||||
}
|
||||
|
||||
function red {
|
||||
bake_fg_color 'RED' "$1"
|
||||
}
|
||||
|
||||
# ----------
|
||||
# - Indent -
|
||||
# ----------
|
||||
|
||||
function bake_indent {
|
||||
exit 0
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
hello:
|
||||
echo 'hi'
|
||||
echo 'there'
|
||||
sleep 1
|
||||
echo hello
|
||||
|
||||
hello/reuse:
|
||||
hello
|
||||
bake hello
|
||||
|
||||
hello/concurrent:
|
||||
bake hello & bake hello
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
TEXT='Hi, there!'
|
||||
|
||||
echo: echo/normal echo/red
|
||||
|
||||
echo/normal:
|
||||
echo "$TEXT"
|
||||
|
||||
echo/red:
|
||||
echo "$TEXT" | red
|
||||
Reference in New Issue
Block a user