mirror of
https://github.com/tonydamage/nux-env.git
synced 2025-12-11 13:24:28 +01:00
Fixed help generation
This commit is contained in:
parent
d3ca4e1b9a
commit
a8f9415ba1
3 changed files with 13 additions and 15 deletions
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env nuxr-nuxsh
|
||||
#!/usr/bin/env nuxsh
|
||||
## Portable *nix environment by tonydamage
|
||||
|
||||
##
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
###
|
||||
### *nuxr-nuxsh* is wrapped bash interpreter for *nux-env* enhanced bash scripts
|
||||
### and provides out of the box support for command-style scripts (similar in
|
||||
### usage such as apt, git) with following features out of the box:
|
||||
### *nuxr-nuxsh* and *nuxsh* is wrapped bash interpreter for *nux-env* enhanced
|
||||
### bash scripts.
|
||||
### It provides out of the box support for command-style scripts
|
||||
### (similar in usage such as apt, git) with following features out of the box:
|
||||
###
|
||||
### task selection::
|
||||
### Automaticly selects correct tasks, displays help if
|
||||
|
|
@ -25,7 +26,7 @@
|
|||
###
|
||||
###
|
||||
### 1. Shebang::
|
||||
### Shebang (*#!*) at the start of file is *#!/usr/bin/env nuxr-nuxsh*
|
||||
### Shebang (*#!*) at the start of file is *#!/usr/bin/env nuxsh*
|
||||
### 2. Tasks::
|
||||
### Script usually does only defines functions in form task {taskname}
|
||||
### where taskname
|
||||
|
|
@ -44,13 +45,10 @@ nux.use nuxr
|
|||
nux.use nux.cfg
|
||||
|
||||
##
|
||||
## Additional commands provided by *nux-runner*:
|
||||
### *nux-runner* automaticly provides following tasks to any script it executes:
|
||||
|
||||
## Additional commands provided by *nuxsh*:
|
||||
### *nuxsh* automaticly provides following tasks to any script it executes:
|
||||
##
|
||||
|
||||
|
||||
|
||||
## debug:: <task> [<task arguments>]
|
||||
## Runs specified task with debug messages enabled.
|
||||
task.debug() {
|
||||
|
|
@ -70,6 +68,7 @@ task.trace() {
|
|||
## documentation.
|
||||
task.help() {
|
||||
nuxr.task.help "$@"
|
||||
echo
|
||||
}
|
||||
|
||||
## config:: [type] name [value]
|
||||
|
|
@ -158,9 +157,8 @@ if [ -n "$NUX_SCRIPT" ]; then
|
|||
|
||||
nuxr.main "$@"
|
||||
else
|
||||
|
||||
echo Usage: nux-runner [script] [task] [options]
|
||||
echo Usage: nuxsh [script] [command] [options]
|
||||
echo
|
||||
grep "^\#\#" "$NUX_RUNNER" | sed -re "s/^#+ ?(.*)/\1/gi" | nux.help.shelldoc
|
||||
nux.help.comment "$NUX_RUNNER"
|
||||
echo
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
nux.use nux/color
|
||||
nux.use nuxr/repl
|
||||
nux.use nux/help
|
||||
|
||||
@prefix check nux.check.
|
||||
@prefix help nux.help.
|
||||
|
|
@ -50,7 +51,6 @@ nux.use nuxr/repl
|
|||
@namespace nuxr.task.help. {
|
||||
|
||||
function : {
|
||||
nux.use nux/help
|
||||
allArgs="$@"
|
||||
if [ -z "$allArgs" ] {
|
||||
echo Usage: $NC_Bold$NUX_SCRIPTNAME ${NC_No}${NC_White}\<command\>${NC_No} [\<options\>]
|
||||
|
|
@ -85,7 +85,7 @@ nux.use nuxr/repl
|
|||
local task_dot=$(tr " " "." <<< "$task")
|
||||
nux.log trace "Trying to figure task documentation location for $task $task_dot"
|
||||
doc_start=$(grep -hn -E "## +($task)::" "$script" | cut -d: -f1)
|
||||
code_start=$(grep -hn -E "((@command +:?$task_dot)|(function +task.$task_dot)|(task.$task_dot *\(\))) +{" "$script" | cut -d: -f1)
|
||||
code_start=$(grep -hn -E "(@command +:?$task_dot)|(function +task.$task_dot)|(task.$task_dot *\(\) +{)" "$script" | cut -d: -f1)
|
||||
nux.log trace "doc_start" $doc_start $code_start
|
||||
if [ -n "$doc_start" -a -n "$code_start" ] {
|
||||
sed -n "$doc_start,$code_start"p "$script" \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue