1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

maint/build ~ improve format and readability of (cargo make) 'help' target

This commit is contained in:
Roy Ivy III 2020-05-02 17:37:02 -05:00
parent d7b6626f70
commit d752d9880b

View file

@ -84,7 +84,7 @@ set_env CARGO_MAKE_TASK_BUILD_UTILS_ARGS "${args}"
### tasks ### tasks
[tasks.default] [tasks.default]
description = "Build and Test" description = "## *DEFAULT* Build and test project"
category = "[project]" category = "[project]"
dependencies = [ dependencies = [
"action-build-debug", "action-build-debug",
@ -92,7 +92,7 @@ dependencies = [
] ]
[tasks.build] [tasks.build]
description = "Build" description = "## Build project"
category = "[project]" category = "[project]"
dependencies = [ dependencies = [
"core::pre-build", "core::pre-build",
@ -101,7 +101,7 @@ dependencies = [
] ]
[tasks.build-features] [tasks.build-features]
description = "Build (with features); usage: `cargo make (build-features | features) FEATURE..`" description = "## Build (with features); usage: `cargo make (build-features | features) FEATURE...`"
category = "[project]" category = "[project]"
dependencies = [ dependencies = [
"core::pre-build", "core::pre-build",
@ -113,7 +113,7 @@ dependencies = [
alias = "build-features" alias = "build-features"
[tasks.format] [tasks.format]
description = "Format" description = "## Format code files (with `cargo fmt`)"
category = "[project]" category = "[project]"
dependencies = [ dependencies = [
"action-format", "action-format",
@ -122,19 +122,20 @@ dependencies = [
] ]
[tasks.help] [tasks.help]
description = "Help" description = "## Display help"
category = "[project]" category = "[project]"
command = "cargo" dependencies = [
args = [ "make", "--list-all-steps" ] "action-display-help",
]
[tasks.install] [tasks.install]
description = "Install project binary (to \"$HOME/.cargo/bin\")" description = "## Install project binary (to $HOME/.cargo/bin)"
category = "[project]" category = "[project]"
command = "cargo" command = "cargo"
args = ["install", "--path", "."] args = ["install", "--path", "."]
[tasks.lint] [tasks.lint]
description = "Lint report" description = "## Display lint report"
category = "[project]" category = "[project]"
dependencies = [ dependencies = [
"action-clippy", "action-clippy",
@ -143,11 +144,9 @@ dependencies = [
[tasks.release] [tasks.release]
alias = "build" alias = "build"
description = "Build"
category = "[project]"
[tasks.test] [tasks.test]
description = "Test" description = "## Run project tests"
category = "[project]" category = "[project]"
dependencies = [ dependencies = [
"core::pre-test", "core::pre-test",
@ -156,7 +155,7 @@ dependencies = [
] ]
[tasks.test-terse] [tasks.test-terse]
description = "Test (with terse/summary output)" description = "## Run project tests (with terse/summary output)"
category = "[project]" category = "[project]"
dependencies = [ dependencies = [
"core::pre-test", "core::pre-test",
@ -165,7 +164,7 @@ dependencies = [
] ]
[tasks.uninstall] [tasks.uninstall]
description = "Remove project binary (from \"$HOME/.cargo/bin\")" description = "## Remove project binary (from $HOME/.cargo/bin)"
category = "[project]" category = "[project]"
command = "cargo" command = "cargo"
args = ["uninstall"] args = ["uninstall"]
@ -174,7 +173,7 @@ args = ["uninstall"]
alias = "utils" alias = "utils"
[tasks.utils] [tasks.utils]
description = "Build (individual) utilities; usage: `cargo make (util | utils | uutil | uutils) [UTIL_NAME..]`" description = "## Build (individual) utilities; usage: `cargo make (util | utils | uutil | uutils) [UTIL_NAME...]`"
category = "[project]" category = "[project]"
dependencies = [ dependencies = [
"core::pre-build", "core::pre-build",
@ -279,3 +278,41 @@ args = [".", "--skip=*/.git,./target,./tests/fixtures", "--ignore-words-list=mut
description = "Test (in `--quiet` mode)" description = "Test (in `--quiet` mode)"
command = "cargo" command = "cargo"
args = ["test", "--quiet", "@@split(CARGO_MAKE_CARGO_BUILD_TEST_FLAGS, )"] args = ["test", "--quiet", "@@split(CARGO_MAKE_CARGO_BUILD_TEST_FLAGS, )"]
[tasks.action-display-help]
script_runner = "@duckscript"
script = [
'''
echo ""
echo "usage: `cargo make TARGET [ARGS...]`"
echo ""
echo "TARGETs:"
echo ""
result = exec "cargo" make --list-all-steps
# set_env CARGO_MAKE_VAR_UTILS ${result.stdout}
# echo ${result.stdout}
lines = split ${result.stdout} "\n"
# echo ${lines}
for line in ${lines}
if not is_empty ${line}
if contains ${line} " - ##"
line_segments = split ${line} " - ##"
desc = array_pop ${line_segments}
desc = trim ${desc}
target = array_pop ${line_segments}
target = trim ${target}
l = length ${target}
r = range 0 20
spacing = set ""
for i in ${r}
if greater_than ${i} ${l}
spacing = set "${spacing} "
end_if
end
echo ${target}${spacing}${desc}
end_if
end_if
end
echo ""
'''
]