diff --git a/dna_add.sh b/dna_add.sh index beadae6682b67a7fcccfaf056621fe144862e954..04d4df8f694e565354cf441447f2955ac3b11498 100755 --- a/dna_add.sh +++ b/dna_add.sh @@ -9,9 +9,9 @@ source "$project_dir"/workflow_commands/log_manager.sh #load the log manager scr help_function() { echo "" - echo "Usage: dna_add Cname Dname [-nocd]" - echo -e "\tCname : path to the container" - echo -e "\tDname : path to the document" + echo "Usage: dna_add container document [-nocd]" + echo -e "\tcontainer : path to the container" + echo -e "\tdocument : path to the document" echo -e "\t-nocd : turn off channel encoding" echo "" exit 1 # Exit script after printing help @@ -42,18 +42,18 @@ channel_coding=true #-----------------------------------------------# while [[ "$#" -gt 0 ]]; do - case "$1" in - -nocd ) channel_coding=false ; shift ;; - -h | --help ) help_function ; exit 1 ;; - -* ) echo "unknown parameter $1" ; exit 1 ;; - * ) if test -z "${container_path:-}" ; then - container_path="${1}" ; shift ; - elif test -z "${document_path:-}" ; then - document_path="${1}" ; shift ; - else - echo "unknown parameter $1" ; exit 1 ; - fi ;; - esac + case "$1" in + -nocd ) channel_coding=false ; shift ;; + -h | --help ) help_function ; exit 1 ;; + -* ) echo "unknown parameter $1" ; exit 1 ;; + * ) if test -z "${container_path:-}" ; then + container_path="${1}" ; shift ; + elif test -z "${document_path:-}" ; then + document_path="${1}" ; shift ; + else + echo "unknown parameter $1" ; exit 1 ; + fi ;; + esac done if test -z "${container_path:-}" diff --git a/dna_create.sh b/dna_create.sh index ce384b630155dfbf396cd3163ad797ce497c9cc1..b1d5c054afebc51a04ec3f131a5e2302f328578d 100755 --- a/dna_create.sh +++ b/dna_create.sh @@ -8,11 +8,11 @@ source "$project_dir"/workflow_commands/metadata_manager.sh #load the xml manage help_function() { echo "" - echo "Usage: dna_create [-sim] [-fl int] [-sp string] Cname" + echo "Usage: dna_create [-sim] [-fl int] [-sp string] container" echo -e "\t-sim : turn on simulator mode" echo -e "\t-fl : specify fragment length [default = 100]" echo -e "\t-sp : specify spacer [default = AAAAAAAACCCCCCCC]" - echo -e "\tCname : name of the container" + echo -e "\tcontainer : name of the container" echo "" exit 1 # Exit script after printing help } @@ -26,15 +26,15 @@ spacer="AAAAAAAACCCCCCCC" ######### ====== read parameters ====== ######### #-----------------------------------------------# -while true; do - case "$1" in - -sim ) simulation=true ; shift ;; - -fl ) frag_length=$2 ; shift 2 ;; - -sp ) spacer=$2 ; shift 2 ;; - -h | --help ) help_function ; exit 1;; - -* ) echo "unknown parameter $1" ; exit 1;; - * ) container_name="${1}" ; break ;; - esac +while [[ "$#" -gt 0 ]]; do + case "$1" in + -sim ) simulation=true ; shift ;; + -fl ) frag_length=$2 ; shift 2 ;; + -sp ) spacer=$2 ; shift 2 ;; + -h | --help ) help_function ; exit 1;; + -* ) echo "unknown parameter $1" ; exit 1;; + * ) container_name="${1}" ; break ;; + esac done int_regex='^[0-9]+$' @@ -49,7 +49,7 @@ then echo "error: spacer ($spacer) is not a dna sequence" ; exit 1 fi -if test -z "$container_name" +if test -z "${container_name:-}" then echo "container name missing" help_function diff --git a/dna_del.sh b/dna_del.sh index 67dcd588d424488a8419163aadb6e29ac385974a..3ae95688c5460d66cc01cb3d2b85774c65aa60ec 100755 --- a/dna_del.sh +++ b/dna_del.sh @@ -8,8 +8,8 @@ source "$project_dir"/workflow_commands/metadata_manager.sh #load the xml manage help_function() { echo "" - echo "Usage: dna_del Cname DI" - echo -e "\tCname : path to the container" + echo "Usage: dna_del container DI" + echo -e "\tcontainer : path to the container" echo -e "\tDI : index of the document to delete" echo "" exit 1 # Exit script after printing help @@ -19,12 +19,30 @@ help_function() { ######### ====== read parameters ====== ######### #-----------------------------------------------# -container_path="${1}" -doc_index="${2}" +while [[ "$#" -gt 0 ]]; do + case "$1" in + -h | --help ) help_function ; exit 1 ;; + -* ) echo "unknown parameter $1" ; exit 1 ;; + * ) if test -z "${container_path:-}" ; then + container_path="${1}" ; shift ; + elif test -z "${doc_index:-}" ; then + doc_index="${1}" ; shift ; + else + echo "unknown parameter $1" ; exit 1 ; + fi ;; + esac +done -if [ "$#" != 2 ] +if test -z "${container_path:-}" then - echo "error invalid number of arguments" + echo "container path missing" + help_function + exit 1 +fi + +if test -z "${doc_index:-}" +then + echo "document index missing" help_function exit 1 fi @@ -37,7 +55,7 @@ fi if [ ! -d "$container_path"/$doc_index ] then - echo "error : $container_path does not contain a document of index $doc_index" + echo "error : container $container_path does not contain a document of index $doc_index" exit 1 fi diff --git a/dna_list.sh b/dna_list.sh index a032fa547e913d38c9dc88b6dcb76b70a1e9acbd..6dbaba0731839fb60282620420283f0f152cdf53 100755 --- a/dna_list.sh +++ b/dna_list.sh @@ -12,19 +12,20 @@ source "$project_dir"/workflow_commands/metadata_manager.sh #load the xml manage help_function() { echo "" - echo "Usage: dna_list Cname" - echo -e "\tCname : path to the container" + echo "Usage: dna_list container" + echo -e "\tcontainer : path to the container" echo "" exit 1 # Exit script after printing help } -container_path="${1}" if [ "$#" != 1 ] then echo "error invalid number of arguments" help_function exit 1 +else + container_path="${1}" fi if [ ! -d "$container_path" ] diff --git a/dna_quick_complete_test.sh b/dna_quick_complete_test.sh index 809c9b9bfa3ea27403d1453deb0b12f8542cb9a3..604591d654efcb0ddbe80cb701c294cc4c47cca4 100755 --- a/dna_quick_complete_test.sh +++ b/dna_quick_complete_test.sh @@ -27,7 +27,7 @@ rm -rf "$container_path" "$commands_dir"/dna_create.sh -sim -fl 100 "$container_path" -call_function "$commands_dir"/dna_add.sh -nocd "$commands_dir"/documents_test/doc.txt "$container_path" +call_function "$commands_dir"/dna_add.sh -nocd "$container_path" "$commands_dir"/documents_test/doc.txt #call_function "$commands_dir"/dna_add.sh -nocd "$commands_dir"/documents_test/img_50.png "$container_path" diff --git a/dna_workflow.sh b/dna_workflow.sh index daafe138715fd78a38e38c1c4a46a5f482533975..ef06ffbb7693c4b7d55cef5301b177a018bc7ca6 100755 --- a/dna_workflow.sh +++ b/dna_workflow.sh @@ -60,7 +60,7 @@ fi call_function "$commands_dir"/dna_create.sh -sim -fl 100 "$container_path" #TODO fl -call_function "$commands_dir"/dna_add.sh "$document_path" "$container_path" +call_function "$commands_dir"/dna_add.sh "$container_path" "$document_path" call_function "$commands_dir"/dna_store.sh "$container_path"