mirror of
https://github.com/tonydamage/nux-env.git
synced 2025-12-11 13:24:28 +01:00
Improved help system.
Signed-off-by: Tony Tkacik <tonydamage@gmail.com>
This commit is contained in:
parent
ff4e509d1c
commit
89010fd209
9 changed files with 233 additions and 133 deletions
16
bin/nux-env
16
bin/nux-env
|
|
@ -1,7 +1,8 @@
|
|||
#!/usr/bin/env nux-runner
|
||||
### Portable *nix environment by tonydamage
|
||||
## Portable *nix environment by tonydamage
|
||||
|
||||
## status - Show status of nux-env installation
|
||||
## status::
|
||||
## Show status of nux-env installation
|
||||
task.status() {
|
||||
echo nux-env folder: $NUX_ENV_DIR
|
||||
pushd $NUX_ENV_DIR > /dev/null
|
||||
|
|
@ -9,7 +10,8 @@ task.status() {
|
|||
popd > /dev/null
|
||||
}
|
||||
|
||||
## update - pulls latest nux-env from repository.
|
||||
## update::
|
||||
## pulls latest nux-env from repository.
|
||||
task.update() {
|
||||
pushd $NUX_ENV_DIR > /dev/null
|
||||
git stash
|
||||
|
|
@ -18,17 +20,17 @@ task.update() {
|
|||
popd > /dev/null
|
||||
}
|
||||
|
||||
## install Install nux-env recommended binaries if not present
|
||||
##
|
||||
## install::
|
||||
## Install nux-env recommended binaries if not present
|
||||
task.install() {
|
||||
:
|
||||
|
||||
}
|
||||
|
||||
## help.inc <inc>
|
||||
## help library:: <inc>
|
||||
## Displays help for specified nuxs-env library.
|
||||
##
|
||||
task.help.inc() {
|
||||
task.help.library() {
|
||||
local name="$1"
|
||||
nux.help.comment $NUX_INC_DIR/$name.inc.sh
|
||||
}
|
||||
|
|
|
|||
116
bin/nux-runner
116
bin/nux-runner
|
|
@ -1,9 +1,38 @@
|
|||
#!/bin/bash
|
||||
|
||||
###
|
||||
### nux-runner is environment runner for nux-env enhanced bash scripts
|
||||
### and provides out of the box support for task-style scripts
|
||||
### (similar in usage such as apt, git).
|
||||
### *nux-runner* 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:
|
||||
###
|
||||
### task selection::
|
||||
### Automaticly selects correct tasks, displays help if
|
||||
### task does not exists.
|
||||
### logging::
|
||||
### Using *nux.log* function and changing output using
|
||||
### *debug*, *trace* prefixes
|
||||
### help display::
|
||||
### Automated help display when no arguments are provided.
|
||||
### Uses source comments as source for help.
|
||||
###
|
||||
###
|
||||
### # Writing nux-runner scripts
|
||||
###
|
||||
### *nux-runner* scripts are basicly bash scripts with some additional conventions.
|
||||
###
|
||||
###
|
||||
###
|
||||
###
|
||||
###
|
||||
### 1. Shebang::
|
||||
### Shebang (*#!*) at the start of file is *#!/usr/bin/env nux-runner*
|
||||
### 2. Tasks::
|
||||
### Script usually does only defines functions in form task.{taskname}
|
||||
### where taskname
|
||||
### ## Defining a task
|
||||
###
|
||||
###
|
||||
###
|
||||
###
|
||||
|
||||
|
||||
|
|
@ -16,39 +45,61 @@ readonly NUX_RUNNER=$NUX_RUNNER_BIN_DIR/nux-runner;
|
|||
nux.include nux-runner
|
||||
|
||||
##
|
||||
## Commands provided by *nux-runner*:
|
||||
|
||||
|
||||
## debug Runs specified task with debug messages enabled.
|
||||
task.debug() {
|
||||
nux.log.level debug
|
||||
nux-runner.run "$@"
|
||||
}
|
||||
|
||||
## trace Runs specified task with debug & trace enabled.
|
||||
task.trace() {
|
||||
nux.log.level trace
|
||||
nux-runner.run "$@"
|
||||
}
|
||||
|
||||
## help Display this help
|
||||
task.help() {
|
||||
echo Usage: $NC_Bold$NUX_SCRIPTNAME ${NC_No}${NC_White}\<command\>${NC_No} [\<options\>]
|
||||
echo
|
||||
grep -E "^\#\#\#( |$)" "$NUX_SCRIPT" | cut -d\# -f4- | cut -d" " -f2- | nux.help.shelldoc
|
||||
echo
|
||||
echo "Available Commands: "
|
||||
nux.help.comment "$NUX_SCRIPT"
|
||||
nux.help.comment "$NUX_RUNNER"
|
||||
nux.exec.optional task.help.detailed
|
||||
}
|
||||
## Additional commands provided by *nux-runner*:
|
||||
### *nux-runner* automaticly provides following tasks to any script it executes:
|
||||
|
||||
##
|
||||
|
||||
|
||||
|
||||
## debug:: <task> [<task arguments>]
|
||||
## Runs specified task with debug messages enabled.
|
||||
task.debug() {
|
||||
nux.log.level debug
|
||||
nuxr.run "$@"
|
||||
}
|
||||
|
||||
## trace:: <task> [<task arguments>]
|
||||
## Runs specified task with debug & trace enabled.
|
||||
task.trace() {
|
||||
nux.log.level trace
|
||||
nuxr.run "$@"
|
||||
}
|
||||
|
||||
## help:: [command]
|
||||
## Display help for command or topic if specified. Otherwise displays
|
||||
## documentation.
|
||||
task.help() {
|
||||
nuxr.task.help "$@"
|
||||
}
|
||||
|
||||
## config:: [type] name [value]
|
||||
## Reads or writes application specific configuration option.
|
||||
###
|
||||
### There are 3 *types* of configuration:
|
||||
### dist::
|
||||
### Distribution provided configuration. Read-only configuration.
|
||||
### global::
|
||||
### Global (user-specific) provided configuration. This configuration is
|
||||
### usually stored in *~/.config/{app-name}/config.yml*
|
||||
### local::
|
||||
### Local configuration.
|
||||
###
|
||||
### The resulting application configuration is merger of these three (if available)
|
||||
### with following preference (most-specific one):
|
||||
### local, global, dist
|
||||
###
|
||||
task.config() {
|
||||
nux.notimplemented task.config
|
||||
}
|
||||
|
||||
task.() {
|
||||
task.help
|
||||
}
|
||||
|
||||
###
|
||||
###
|
||||
|
||||
if [ "$NUX_RUNNER" = "$(realpath "$0")" ]
|
||||
then
|
||||
readonly NUX_SCRIPT=$1;
|
||||
|
|
@ -61,12 +112,13 @@ fi
|
|||
if [ -n "$NUX_SCRIPT" ]; then
|
||||
# Determines script
|
||||
readonly NUX_SCRIPTNAME=$(basename $NUX_SCRIPT)
|
||||
|
||||
nux-runner.run "$@"
|
||||
readonly NUX_APPNAME=$(basename $NUX_SCRIPT)
|
||||
nuxr.run "$@"
|
||||
|
||||
else
|
||||
|
||||
echo Usage: nux-runner [script] [task] [options]
|
||||
echo
|
||||
grep "^\#\#\# " "$NUX_RUNNER" | cut -d\# -f4-
|
||||
grep "^\#\#" "$NUX_RUNNER" | sed -re "s/^#+ ?(.*)/\1/gi" | nux.help.shelldoc
|
||||
echo
|
||||
fi
|
||||
|
|
|
|||
76
bin/nuxfs
76
bin/nuxfs
|
|
@ -1,30 +1,30 @@
|
|||
#!/usr/bin/env nux-runner
|
||||
|
||||
### # nuxfs - Filesystem layout manager
|
||||
###
|
||||
### *nuxfs* command uses file structure definition present in *.nuxfs* file
|
||||
### to understand intented state of directory / filesystem of user.
|
||||
###
|
||||
### This definition is not only used to create filesystem hierarchy, checkout
|
||||
### git repositories but also to verify state of filesystem afterwards.
|
||||
###
|
||||
### ## Example of .nuxfs file in home directory
|
||||
###
|
||||
### *dir* github
|
||||
### *git* nux-env https://github.com/tonydamage/nux-env.git
|
||||
### *git* bats https://github.com/sstephenson/bats.git
|
||||
### *enddir*
|
||||
### *link* .bashrc github/nux-env/bashrc
|
||||
###
|
||||
### This *.nuxfs* file describes simple home structure. If we execute
|
||||
### **nuxfs apply** command, it will performs filesystem changes in order to
|
||||
### recreate structure described in *.nuxfs* file. In case of example it is
|
||||
### equivalent of executing:
|
||||
### mkdir -p github
|
||||
### git clone https://github.com/tonydamage/nux-env.git github/nux-env
|
||||
### git clone https://github.com/sstephenson/bats.git
|
||||
### ln -s github/nux-env/bashrc .bashrc
|
||||
###
|
||||
## # nuxfs - Filesystem layout manager
|
||||
##
|
||||
## *nuxfs* command uses file structure definition present in *.nuxfs* file
|
||||
## to understand intented state of directory / filesystem of user.
|
||||
##
|
||||
## This definition is not only used to create filesystem hierarchy, checkout
|
||||
## git repositories but also to verify state of filesystem afterwards.
|
||||
##
|
||||
## ## Example of .nuxfs file in home directory
|
||||
##
|
||||
## *dir* github
|
||||
## *git* nux-env https://github.com/tonydamage/nux-env.git
|
||||
## *git* bats https://github.com/sstephenson/bats.git
|
||||
## *enddir*
|
||||
## *link* .bashrc github/nux-env/bashrc
|
||||
##
|
||||
## This *.nuxfs* file describes simple home structure. If we execute
|
||||
## **nuxfs apply** command, it will performs filesystem changes in order to
|
||||
## recreate structure described in *.nuxfs* file. In case of example it is
|
||||
## equivalent of executing:
|
||||
## mkdir -p github
|
||||
## git clone https://github.com/tonydamage/nux-env.git github/nux-env
|
||||
## git clone https://github.com/sstephenson/bats.git
|
||||
## ln -s github/nux-env/bashrc .bashrc
|
||||
##
|
||||
|
||||
local WORKDIR=$(pwd)
|
||||
local TEMPLATE_DIR=$NUX_ENV_DIR/templates
|
||||
|
|
@ -37,9 +37,14 @@ nux.use nuxfs
|
|||
|
||||
GIT_BIN=$(which git)
|
||||
|
||||
## check Verifies that directories and files matches the specification
|
||||
## in *.nuxfs* definition
|
||||
##
|
||||
## Available commands:
|
||||
|
||||
## check:: [<subtree>]
|
||||
## Verifies that directories and files matches the specification
|
||||
## in *.nuxfs* definition
|
||||
###
|
||||
### Check is non-descructive operation, whose only output is printing out
|
||||
### information
|
||||
task.check() {
|
||||
nuxfs.dsl.process "$@";
|
||||
}
|
||||
|
|
@ -48,22 +53,25 @@ task.describe() {
|
|||
nuxfs.dsl.process "$@";
|
||||
}
|
||||
|
||||
## apply Creates missing files as specified in *.nuxfs* definition.
|
||||
## **DOES NOT MODIFY** existing files breaking specification.
|
||||
## apply:: [<subtree>]
|
||||
## Creates missing files as specified in *.nuxfs* definition.
|
||||
## **DOES NOT MODIFY** existing files breaking specification.
|
||||
##
|
||||
task.apply() {
|
||||
nuxfs.dsl.process "$@";
|
||||
}
|
||||
|
||||
## fix Performs apply and tries to fix warnings and errors and files as
|
||||
## specified in nuxfs definition. This operation **DOES MODIFY**
|
||||
## existing files.
|
||||
## fix:: [<subtree>]
|
||||
## Performs apply and tries to fix warnings and errors and files as
|
||||
## specified in nuxfs definition. This operation **DOES MODIFY**
|
||||
## existing files.
|
||||
##
|
||||
task.fix() {
|
||||
nuxfs.dsl.process "$@";
|
||||
}
|
||||
|
||||
## help.dsl Displays help for **nuxfs DSL language**
|
||||
## help dsl::
|
||||
## Displays help for **nuxfs DSL language**
|
||||
##
|
||||
task.help.dsl() {
|
||||
nux.help.comment "$NUX_INC_DIR/dsl/nuxfs.dsl"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
|
||||
type ffmpeg > /dev/null 2>&1 && FFMPEG_OR_LIBAV=ffmpeg
|
||||
type avconv > /dev/null 2>&1 && FFMPEG_OR_LIBAV=avconv
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue