task dont parse options anymore, and taskrc file typo corrected

This commit is contained in:
Thomas Di Grégorio 2018-07-02 23:01:21 +02:00
parent 99e039dbc3
commit de1cf96a45
2 changed files with 22 additions and 24 deletions

View File

@ -22,10 +22,10 @@ $(read -r -p Need\ some\ infos\ for\ task\ $TASK_NAME\ \(\ \hit\ enter\ \)\ v)
## ##
## ##
# write tour default options here # write your default options here
source easyoptions || exit source easyoptions || exit
verbose() { [[ -n "$verbose" ]] && echo $1; } verbose() { [[ -n "\$verbose" ]] && echo \$1; }
##### YOUR CODE HERE ##### ##### YOUR CODE HERE #####
@ -64,17 +64,23 @@ verbose() { [[ -n "$verbose" ]] && echo $1; }
################################################################################ ################################################################################
__dirname="$(dirname $0)" __dirname="\$(dirname \$0)"
__dirtask="$__dirname/.$(basename $0)" __dirtask="\$__dirname/.\$(basename \$0)"
__taskargs=\$(echo "\${@:1}" | sed "s/\${arguments[0]} //")
# Calls command (1rt argument) as script or function \$1( \$2 \$3 ... ) # Calls command (1rt argument) as script or function \$1( \$2 \$3 ... )
if [ -r "$__dirtask/$1" ] if [ -r "\$__dirtask/\${arguments[0]}" ]
verbose "Command file exists call it: \$__dirtask/\$1 \${*:2}" then
\$__dirtask/\$1 \${*:2} verbose "Command file exists call it: \$__dirtask/\${arguments[0]} \$__taskargs"
\$__dirtask/\${arguments[0]} \$__taskargs
else else
if [ -n "$(type -t $1)" ] && [ "$(type -t $1)" = function ]; if [ -n "\$(type -t \${arguments[0]})" ] && [ "\$(type -t \${arguments[0]})" = function ];
then then
verbose "\$__dirtask/\$1 not exists try func: \$1 \${*:2}" verbose "\$__dirtask/\${arguments[0]} do not exists, trying function: \${arguments[0]} \$__taskargs"
\$1 "\${*:2}" \${arguments[0]} \$__taskargs
fi fi
fi fi

View File

@ -28,8 +28,8 @@
# defaults ex: (uncomment) # defaults ex: (uncomment)
#option1=coucou #option1=coucou
source easyoptions || exit #source easyoptions || exit
verbose() { [[ -n "$verbose" ]] && echo $1; } #verbose() { [[ -n "$verbose" ]] && echo $1; }
@ -49,20 +49,12 @@ create()
} }
if [ -n "$verbose" ] # Boolean and parameter options
then [[ $1 == "--create" ]] && create ${@:2}
# Arguments [[ $1 == "-c" ]] && create ${@:2}
for argument in "${arguments[@]}"; do
echo "Argument specified: $argument"
done
fi
[[ -n "$create" ]] && create ${arguments[@]}
################################################################################ ################################################################################
# Calls command (1rt argument) as function \$1( \$2 \$3 ... ) # Calls command (1rt argument) as function $1( $2 $3 ... )
$PWD/.tasks/$1 ${@:2} $PWD/.tasks/$1 ${@:2}