Browse Source

ajout du nom de la tâche en parametre

nas 3 years ago
parent
commit
89879ef6e9
1 changed files with 18 additions and 14 deletions
  1. 18
    14
      pert

+ 18
- 14
pert View File

@@ -21,15 +21,15 @@ function _help
21 21
 {
22 22
     _echo ""
23 23
     _echoB "A command line PERT calculator for quick estimates."
24
-    _echo "Comma separated task list in the form \"1,2,12 4,5,9 2,3,6\", where whitespace separates tasks."
24
+    _echo "Comma separated task list in the form \"one,1,2,12 two,4,5,9 three,2,3,6\", where whitespace separates tasks."
25 25
     _echo ""
26 26
     _echoB "Usage:"
27
-    _echo "\tpert [optimistic,realistic,pessimistic]"
27
+    _echo "\tpert [name,optimistic,realistic,pessimistic]"
28 28
     _echo ""
29 29
     _echoB "Example:"
30
-    _echo "\tpert 1,3,4"
31
-    _echo "\tpert 10,15,20 5,7,10"
32
-    _echo "\tpert \"1,2,3\" \"15,17,20\""
30
+    _echo "\tpert one,1,3,4"
31
+    _echo "\tpert one,10,15,20 two,5,7,10"
32
+    _echo "\tpert \"one,1,2,3\" \"two,15,17,20\""
33 33
     _echo ""
34 34
 }
35 35
 
@@ -51,7 +51,7 @@ readonly format=" | %-12s |${green}%11s${normal} |%10s |${red}%12s${normal} |%9s
51 51
 function _header
52 52
 {
53 53
     _echo ""
54
-    _echoB "Tasks"
54
+    _echoB "Task"
55 55
     _echo ""
56 56
     _divider
57 57
     printf "$format" "#" "optimistic" "realistic" "pessimistic" "duration" "risk" "variance"
@@ -75,28 +75,32 @@ function pert_table
75 75
 
76 76
         # split values
77 77
         IFS=',' read -ra ADDR <<< "$var"
78
+o="0"
79
+        if [ -n "${ADDR[0]-}" ]; then
80
+            t=${ADDR[0]}
81
+        fi
78 82
 
79 83
         # optimistic value
80 84
         o="0"
81
-        if [ -n "${ADDR[0]-}" ]; then
82
-            o=${ADDR[0]}
85
+        if [ -n "${ADDR[1]-}" ]; then
86
+            o=${ADDR[1]}
83 87
         fi
84 88
 
85 89
         # realistic value
86 90
         r="0"
87
-        if [ -n "${ADDR[1]-}" ]; then
88
-            r=${ADDR[1]}
91
+        if [ -n "${ADDR[2]-}" ]; then
92
+            r=${ADDR[2]}
89 93
         fi
90 94
 
91 95
         # pessimistic value
92 96
         p="0"
93
-        if [ -n "${ADDR[2]-}" ]; then
94
-            p=${ADDR[2]}
97
+        if [ -n "${ADDR[3]-}" ]; then
98
+            p=${ADDR[3]}
95 99
         fi
96 100
 
97 101
         # check values
98 102
         if [ -z "$o" ] || [ -z "$r" ] || [ -z "$p" ]; then
99
-            printf "$format" "$counter. bad input" $o $r $p
103
+            printf "$format" "$counter. bad input" $t $o $r $p
100 104
         else
101 105
 
102 106
             # pert estimate
@@ -112,7 +116,7 @@ function pert_table
112 116
             total_variance=$(_calc "$total_variance + $variance")
113 117
 
114 118
             # row
115
-            printf "$format" "$counter. task" $o $r $p $pert_estimate $standard_deviation $variance
119
+            printf "$format" "$counter."$t $o $r $p $pert_estimate $standard_deviation $variance
116 120
         fi
117 121
 
118 122
     done

Loading…
Cancel
Save