-
Notifications
You must be signed in to change notification settings - Fork 0
/
updwn.py
53 lines (48 loc) · 1.86 KB
/
updwn.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import sys
import random
from azureFileManager import AzureFileManager
from utilities import print_blue, print_green, print_red
def perform_commands():
""" handle command line interface """
args = sys.argv
args = args[1:] # Skip file name
if len(args) == 0:
print('You should pass command, please use --help for more info')
else:
# create AzureFileManager
afm = AzureFileManager()
# command name
command = args[0]
if command == '--help':
print_blue('Upload/Download command line interface')
print_green('Commands:')
print_green(' updwn --upload <upload path> <file path>')
print_green(' updwn --download <path>')
print_green(' updwn --list')
print('')
elif command == '--upload':
if len(args)is not 3:
print_red(
"Incorrect parameters, please use correct one -> updwn --upload <upload path> <file path>")
exit(1)
upload_path = args[1]
file_name = args[2]
afm.upload_file(upload_path, file_name)
elif command == '--download':
if len(args)is not 2:
print_red(
"Incorrect parameters, please use correct one -> updwn --download <path>")
exit(1)
path = args[1]
afm.download_file(path)
elif command == '--list':
if len(args)is not 1:
print_red(
"Incorrect format, please use correct one -> updwn --list")
exit(1)
print_blue("========= List of all files ========= ")
afm.get_list_of_files()
else:
print_red('Unrecognised argument.')
if __name__ == '__main__':
perform_commands()