3
3
OPT=$( getopt -n " cf-dns" -o " h,v" -l " help,version,register:,movies,order:,history,cancel:,recoverKey:,userkey:,locations,movieID:,movieName:,theaterID:,city:,country:" -- " $@ " )
4
4
5
5
eval set -- " $OPT "
6
- hF=0
7
- vF=0
6
+ # flags
8
7
registerF=0
9
8
moviesF=0
10
9
orderF=0
11
10
historyF=0
12
11
cancelF=0
13
12
restoreF=0
14
- username=" "
15
- password=" "
16
13
locationsF=0
17
14
movieInfoF=0
15
+ # default values
16
+ username=" "
17
+ password=" "
18
18
userKey=$GLOBAL_USER_KEY
19
+ # decoration
19
20
format=" %3s | %-12s | %-15s | %-50s\n" # format for output
21
+ # server address link
22
+ server_address=" http://localhost"
20
23
21
24
# check correct format of credentials i.ex : username:password
22
25
function check_creds(){
@@ -33,20 +36,69 @@ function check_creds(){
33
36
fi
34
37
# check not empty credentials
35
38
if [ -z " $password " ] || [ -z " $username " ]; then
36
- echo " client : Username and pussword can not be empty!"
37
-
39
+ echo " client : Username and pussword can not be empty!"
38
40
exit 1
39
41
fi
40
42
}
41
43
42
44
45
+ # version
46
+ function versionShow(){
47
+ echo -e " Linux environment programming: \n\nVersion 1.0\n
48
+ Authors:\n-----------------------\nLiran Rotenberg\nJohnatan Leon\nIsabelle Meif\nAlexey Silyuk\n"
49
+ exit
50
+ }
51
+
52
+ # Synopsis
53
+ function help(){
54
+ echo " Movie tickets ordering system :
55
+
56
+ ./client -h : this synopsis
57
+ ./client -v : version with authors names
58
+
59
+ Register to system:
60
+ ./client --register username:password
61
+
62
+ Recover lost userkey:
63
+ ./client --recoverKey <USERNAME>:<PASSWORD>
64
+
65
+ View movies :
66
+ All movies:
67
+ ./client --movies
68
+
69
+ By ID:
70
+ ./client --movieID <MOVIEID>
71
+
72
+ By Name (or part of name,prefix):
73
+ ./client --movieName \" MOVIE NAME\"
74
+
75
+ View locations:
76
+ All without filtering:
77
+ ./client --locations
78
+
79
+ By ID:
80
+ ./client --locationID <ID>
81
+
82
+ By Country:
83
+ ./client --locations --country <COUNTRY>, may be used country prefix
84
+
85
+ By City:
86
+ ./client --locations --city <CITY> , may be used city prefix
87
+
88
+ Ordering :
89
+ UNDER CONSTRUCTION
90
+
91
+ "
92
+ exit
93
+ }
94
+
43
95
while [ " $1 " != " --" ]; do
44
96
case " $1 " in
45
97
-h|--help)
46
- hF=1
98
+ help
47
99
;;
48
100
-v|--version)
49
- vF=1
101
+ versionShow
50
102
;;
51
103
--register)
52
104
register_credentials=" $2 "
@@ -122,49 +174,6 @@ if ! [ -z "$2" ]; then
122
174
exit 1
123
175
fi
124
176
125
- # version
126
- if [ " $vF " -eq 1 ]; then
127
- echo " Linux project version 1.0"
128
- fi
129
-
130
-
131
- # Synopsis
132
- if [ " $hF " -eq 1 ]; then
133
- echo " Movie ordering system :
134
- ./client -h : this synopsis
135
-
136
- Register to system:
137
- ./client --register username:password
138
-
139
- Recover lost userkey:
140
- ./client --recoverKey <USERNAME>:<PASSWORD>
141
-
142
- View movies :
143
- All movies:
144
- ./client --movies
145
-
146
- By ID:
147
- ./client --movieID <MOVIEID>
148
-
149
- By Name (or part of name,prefix):
150
- ./client --movieName \" MOVIE NAME\"
151
-
152
- View locations:
153
- All without filtering:
154
- ./client --locations
155
-
156
- By ID:
157
- ./client --locationID <ID>
158
-
159
- By Country:
160
- ./client --locations --country <COUNTRY>, may be used country prefix
161
-
162
- By City:
163
- ./client --locations --city <CITY> , may be used city prefix
164
-
165
- "
166
- exit
167
- fi
168
177
169
178
# Register
170
179
if [ " $registerF " == 1 ]; then
0 commit comments