task dont parse options anymore, and taskrc file typo corrected
This commit is contained in:
parent
99e039dbc3
commit
de1cf96a45
|
@ -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
|
||||
verbose() { [[ -n "$verbose" ]] && echo $1; }
|
||||
verbose() { [[ -n "\$verbose" ]] && echo \$1; }
|
||||
|
||||
##### YOUR CODE HERE #####
|
||||
|
||||
|
@ -64,17 +64,23 @@ verbose() { [[ -n "$verbose" ]] && echo $1; }
|
|||
|
||||
|
||||
################################################################################
|
||||
__dirname="$(dirname $0)"
|
||||
__dirtask="$__dirname/.$(basename $0)"
|
||||
__dirname="\$(dirname \$0)"
|
||||
__dirtask="\$__dirname/.\$(basename \$0)"
|
||||
__taskargs=\$(echo "\${@:1}" | sed "s/\${arguments[0]} //")
|
||||
|
||||
|
||||
# Calls command (1rt argument) as script or function \$1( \$2 \$3 ... )
|
||||
if [ -r "$__dirtask/$1" ]
|
||||
verbose "Command file exists call it: \$__dirtask/\$1 \${*:2}"
|
||||
\$__dirtask/\$1 \${*:2}
|
||||
if [ -r "\$__dirtask/\${arguments[0]}" ]
|
||||
then
|
||||
verbose "Command file exists call it: \$__dirtask/\${arguments[0]} \$__taskargs"
|
||||
\$__dirtask/\${arguments[0]} \$__taskargs
|
||||
else
|
||||
if [ -n "$(type -t $1)" ] && [ "$(type -t $1)" = function ];
|
||||
if [ -n "\$(type -t \${arguments[0]})" ] && [ "\$(type -t \${arguments[0]})" = function ];
|
||||
then
|
||||
verbose "\$__dirtask/\$1 not exists try func: \$1 \${*:2}"
|
||||
\$1 "\${*:2}"
|
||||
verbose "\$__dirtask/\${arguments[0]} do not exists, trying function: \${arguments[0]} \$__taskargs"
|
||||
\${arguments[0]} \$__taskargs
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
|
20
tasks/task
20
tasks/task
|
@ -28,8 +28,8 @@
|
|||
# defaults ex: (uncomment)
|
||||
#option1=coucou
|
||||
|
||||
source easyoptions || exit
|
||||
verbose() { [[ -n "$verbose" ]] && echo $1; }
|
||||
#source easyoptions || exit
|
||||
#verbose() { [[ -n "$verbose" ]] && echo $1; }
|
||||
|
||||
|
||||
|
||||
|
@ -49,20 +49,12 @@ create()
|
|||
}
|
||||
|
||||
|
||||
if [ -n "$verbose" ]
|
||||
then
|
||||
# Arguments
|
||||
for argument in "${arguments[@]}"; do
|
||||
echo "Argument specified: $argument"
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
[[ -n "$create" ]] && create ${arguments[@]}
|
||||
|
||||
# Boolean and parameter options
|
||||
[[ $1 == "--create" ]] && create ${@:2}
|
||||
[[ $1 == "-c" ]] && create ${@:2}
|
||||
|
||||
|
||||
################################################################################
|
||||
|
||||
# Calls command (1rt argument) as function \$1( \$2 \$3 ... )
|
||||
# Calls command (1rt argument) as function $1( $2 $3 ... )
|
||||
$PWD/.tasks/$1 ${@:2}
|
||||
|
|
Loading…
Reference in New Issue