Bash command line help scripts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.6 KiB

#!/bin/bash
## Task v0.1.0
## Copyright (C) Thomas Di gregorio
## Licensed under MIT (should be GPL because of easyoptions?)
##
## Launch a task in the current working dir's .task folder.
## Or create a new task chmoded u+x in current working dir's .task folder
## ( .tasks folder is created if not present ).
## Usage:
## @script.name [-c NAME [NAMES]] | TASK ARGUMENTS...
##
## Options:
## ( Long version are mandatory, and can be before or after short version )
##
## -h, --help Show this help.
## -v, --verbose Show sub-task resolution and options parsed.
## -c, --create Search a module (default) on odoo.com website.
##
## Exemples:
## task --create foo
## task -c foo --sub-tasks=bar,baz
## task foo --help
## task foo bar --option arg1 arg2 -c
## task foo help bar
# defaults ex: (uncomment)
#option1=coucou
#source easyoptions || exit
#verbose() { [[ -n "$verbose" ]] && echo $1; }
create()
{
# Test if .tasks folder exists first and create it
[[ ! -d "$PWD/.tasks" ]] && mkdir $PWD/.tasks && verbose "Missing .tasks/ folder,... created !"
# TODO then the same for sub-tasks
TASK_PATH=$PWD/.tasks/$1
TASK_NAME=$1 .taskrc > $TASK_PATH
chmod u+x $TASK_PATH
nano $TASK_PATH
exit;
}
# Boolean and parameter options
[[ $1 == "--create" ]] && create ${@:2}
[[ $1 == "-c" ]] && create ${@:2}
################################################################################
# Calls command (1rt argument) as function $1( $2 $3 ... )
$PWD/.tasks/$1 ${@:2}