Refactored template creation
Fix obsolete escapes in sequencer help output
This commit is contained in:
@@ -40,7 +40,7 @@ Usage: ${0##*/} [OPTIONS] [STEP NUMBER(s) or ALIAS] [STEP ARGUMENTS]
|
|||||||
--help, -h : Display help
|
--help, -h : Display help
|
||||||
--helpapi, -ha : Display help about build-in supporting functions
|
--helpapi, -ha : Display help about build-in supporting functions
|
||||||
(e.g. exe,addconf,echerr,...)
|
(e.g. exe,addconf,echerr,...)
|
||||||
--profile, -p : Sequence configuration profile name (default: \"default\")
|
--profile, -p : Sequence configuration profile name (default: "default")
|
||||||
If supported by seq
|
If supported by seq
|
||||||
--quiet, -q : Don't ask for permission to execute steps
|
--quiet, -q : Don't ask for permission to execute steps
|
||||||
If called without starting step number, only this help is shown
|
If called without starting step number, only this help is shown
|
||||||
@@ -51,11 +51,11 @@ Usage: ${0##*/} [OPTIONS] [STEP NUMBER(s) or ALIAS] [STEP ARGUMENTS]
|
|||||||
( e.g.: exe apt update )
|
( e.g.: exe apt update )
|
||||||
--version : Display version of sequencer and revision of sequence
|
--version : Display version of sequencer and revision of sequence
|
||||||
|
|
||||||
[STEP NUMBER\"(s)\" 1-${MAX_STEP} or ALIAS]
|
[STEP NUMBER"(s)" 1-${MAX_STEP} or ALIAS]
|
||||||
No STEP or ALIAS : assume 1 as starting point
|
No STEP or ALIAS : assume 1 as starting point
|
||||||
Single STEP or ALIAS : starting point of sequential process
|
Single STEP or ALIAS : starting point of sequential process
|
||||||
Multiple STEPS or ALIAS : execute only given steps
|
Multiple STEPS or ALIAS : execute only given steps
|
||||||
(e.g. $0 \"2 4 12\")
|
(e.g. $0 "2 4 12")
|
||||||
multiple steps need to be given as string
|
multiple steps need to be given as string
|
||||||
[STEP ARGUMENTS]
|
[STEP ARGUMENTS]
|
||||||
* : Arguments will be passed to selected steps and step infos as:
|
* : Arguments will be passed to selected steps and step infos as:
|
||||||
@@ -100,7 +100,7 @@ sequencer.sh build-in functions:
|
|||||||
Supporting: dry-run (-d): only print command without execution
|
Supporting: dry-run (-d): only print command without execution
|
||||||
verbose (-v): print command before execution
|
verbose (-v): print command before execution
|
||||||
|
|
||||||
exep \"[COMMANDLINE]\"
|
exep "[COMMANDLINE]"
|
||||||
See exe, but support for pipes or redirects.
|
See exe, but support for pipes or redirects.
|
||||||
Important:
|
Important:
|
||||||
- Shell commands cd, read, ... won't work because COMMANDLINE is started in a new shell.
|
- Shell commands cd, read, ... won't work because COMMANDLINE is started in a new shell.
|
||||||
@@ -122,7 +122,7 @@ sequencer.sh build-in functions:
|
|||||||
addConf <OPTIONS> [SOURCE TYPE] <SOURCE> <DESTINATION FILE>
|
addConf <OPTIONS> [SOURCE TYPE] <SOURCE> <DESTINATION FILE>
|
||||||
Trying to write or append text or a file (<SOURCE>) to a destination file.
|
Trying to write or append text or a file (<SOURCE>) to a destination file.
|
||||||
If the CONFIGFILE exists, a backup (name_%Y%m%d-%H%M%S.bck) is saved at the same location.
|
If the CONFIGFILE exists, a backup (name_%Y%m%d-%H%M%S.bck) is saved at the same location.
|
||||||
If -s fails or -m, \"$(realpath "$MISSING_CONF")\" is created with the conflicts
|
If -s fails or -m, "$(realpath "$MISSING_CONF")" is created with the conflicts
|
||||||
to be resolved by the user.
|
to be resolved by the user.
|
||||||
<OPTIONS>
|
<OPTIONS>
|
||||||
-c : create a new file
|
-c : create a new file
|
||||||
@@ -680,41 +680,47 @@ createTemplate() {
|
|||||||
if [ -f $TEMPLATE_NAME ] ; then
|
if [ -f $TEMPLATE_NAME ] ; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
echo "#!/bin/bash" > $TEMPLATE_NAME
|
cat > $TEMPLATE_NAME << TEMPLATE_EOF
|
||||||
echo >> $TEMPLATE_NAME
|
#!/bin/bash
|
||||||
echo "toolName=mytool" >> $TEMPLATE_NAME
|
|
||||||
echo >> $TEMPLATE_NAME
|
toolName=mytool
|
||||||
echo "# Get script working directory" >> $TEMPLATE_NAME
|
|
||||||
echo "# (when called from a different directory)" >> $TEMPLATE_NAME
|
# Get script working directory
|
||||||
echo "WDIR=\"\$( cd \"\$( dirname \"\${BASH_SOURCE[0]}\" )\" >>/dev/null 2>&1 && pwd )\"" >> $TEMPLATE_NAME
|
# (when called from a different directory)
|
||||||
echo "CONFIG=0" >> $TEMPLATE_NAME
|
WDIR="\$(cd "\$(dirname "\${BASH_SOURCE[0]}")" >>/dev/null 2>&1 && pwd)"
|
||||||
echo "CONFIG_FILE_NAME=\"\${toolName}.cfg\"" >> $TEMPLATE_NAME
|
CONFIG=0
|
||||||
echo "CONFIG_FILE_TEMPLATE=\"\$WDIR/\${CONFIG_FILE_NAME}.example\"" >> $TEMPLATE_NAME
|
SCRIPT_NAME=\$(basename -- \$0)
|
||||||
echo >> $TEMPLATE_NAME
|
SCRIPT_NAME=\${SCRIPT_NAME%%.*}
|
||||||
echo "step_config() {" >> $TEMPLATE_NAME
|
CONFIG_FILE_NAME="\${SCRIPT_NAME}.cfg"
|
||||||
echo " echo \"Called once before executing steps.\"" >> $TEMPLATE_NAME
|
CONFIG_FILE_TEMPLATE="\$WDIR/\${CONFIG_FILE_NAME}.example"
|
||||||
echo " ## e.g. to source a config file manually:" >> $TEMPLATE_NAME
|
|
||||||
echo " #. \"\$CONFIG_FILE\"" >> $TEMPLATE_NAME
|
step_config() {
|
||||||
echo " ## or to use sequencer api:" >> $TEMPLATE_NAME
|
echo "Called once before executing steps."
|
||||||
echo " #initSeqConfig \"\$CONFIG_FILE_NAME\" \"\$CONFIG_FILE_TEMPLATE\"" >> $TEMPLATE_NAME
|
## e.g. to source a config file manually:
|
||||||
echo " #if [ \$? -eq 0 ] ; then" >> $TEMPLATE_NAME
|
#. "\$CONFIG_FILE"
|
||||||
echo " # CONFIG=1" >> $TEMPLATE_NAME
|
## or to use sequencer api with global config file:
|
||||||
echo " #fi" >> $TEMPLATE_NAME
|
#initSeqConfig "\$CONFIG_FILE_NAME" "\$CONFIG_FILE_TEMPLATE"
|
||||||
echo "}" >> $TEMPLATE_NAME
|
## or to use sequencer api with profile config file support:
|
||||||
echo >> $TEMPLATE_NAME
|
#initSeqConfig -p "\$SCRIPT_NAME" "\$CONFIG_FILE_TEMPLATE"
|
||||||
echo "step_1_info() { echo \"My custom step\"; }" >> $TEMPLATE_NAME
|
#if [ \$? -eq 0 ] ; then
|
||||||
echo "step_1_alias() { ALIAS=\"begin\"; }" >> $TEMPLATE_NAME
|
# CONFIG=1
|
||||||
echo "step_1() {" >> $TEMPLATE_NAME
|
#fi
|
||||||
echo " echo \"Doing something for step \$1 ...\"" >> $TEMPLATE_NAME
|
}
|
||||||
echo " echo \"Command line arguments starting with argument 2: \$@\"" >> $TEMPLATE_NAME
|
|
||||||
echo " # Use exe for regular command" >> $TEMPLATE_NAME
|
step_1_info() { echo "My custom step"; }
|
||||||
echo " # Use exep \"command\" for commands containing pipes or redirects" >> $TEMPLATE_NAME
|
step_1_alias() { ALIAS="begin"; }
|
||||||
echo " exe ls" >> $TEMPLATE_NAME
|
step_1() {
|
||||||
echo " exep \"dmesg | grep usb\"" >> $TEMPLATE_NAME
|
echo "Doing something for step \$1 ..."
|
||||||
echo "}" >> $TEMPLATE_NAME
|
echo "Command line arguments starting with argument 2: \$@"
|
||||||
echo >> $TEMPLATE_NAME
|
# Use exe for regular command
|
||||||
echo "VERSION_SEQREV=${VERSION_REV}" >> $TEMPLATE_NAME
|
# Use exep "command" for commands containing pipes or redirects
|
||||||
echo ". $0" >> $TEMPLATE_NAME
|
exe ls
|
||||||
|
exep "dmesg | grep usb"
|
||||||
|
}
|
||||||
|
|
||||||
|
VERSION_SEQREV=${VERSION_REV}
|
||||||
|
. $0
|
||||||
|
TEMPLATE_EOF
|
||||||
|
|
||||||
chmod +x $TEMPLATE_NAME
|
chmod +x $TEMPLATE_NAME
|
||||||
return 0
|
return 0
|
||||||
|
Reference in New Issue
Block a user