Skip to content

Commit 13bdefe

Browse files
committed
Adjust commands and options to be me intuitive. Add help text.
1 parent 0b69287 commit 13bdefe

File tree

1 file changed

+52
-29
lines changed

1 file changed

+52
-29
lines changed

ascent/ascent/cli.py

Lines changed: 52 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -52,33 +52,23 @@ def global_options(func):
5252
return func
5353

5454

55-
_upload_options = [
56-
click.option(
57-
"--path",
58-
required=True,
59-
type=click.Path(exists=True, readable=True, path_type=Path),
60-
help="Local location of items(s) to upload"
61-
),
62-
click.option(
63-
"--parent-folder",
55+
_upload_arguments = [
56+
click.argument(
57+
"folder-name",
6458
type=str,
65-
help="""
66-
ID of girder folder that will be the parent of created folder.
67-
Defaults to user root.
68-
"""
59+
required=True,
6960
),
70-
click.option(
71-
"--folder-name",
72-
type=str,
61+
click.argument(
62+
"path",
7363
required=True,
74-
help="Unique folder name"
75-
)
64+
type=click.Path(exists=True, readable=True, path_type=Path),
65+
),
7666

7767
]
7868

7969

80-
def upload_options(func):
81-
for option in _upload_options:
70+
def upload_arguments(func):
71+
for option in _upload_arguments:
8272
func = option(func)
8373
return func
8474

@@ -101,11 +91,6 @@ def login(api, port):
10191
return gc
10292

10393

104-
@click.group()
105-
def ascent():
106-
pass
107-
108-
10994
def create_folder(parent_folder, folder_name, gc):
11095
new_folder = None
11196
try:
@@ -130,18 +115,34 @@ def create_folder(parent_folder, folder_name, gc):
130115
return new_folder
131116

132117

118+
@click.group()
119+
def ascent():
120+
"""A cli to interact with the DIVE API """
121+
pass
122+
123+
133124
@ascent.group()
134125
def upload():
135126
pass
136127

137128

138129
@upload.command()
130+
@upload_arguments
139131
@global_options
140-
@upload_options
132+
@click.option(
133+
"--parent-folder",
134+
type=str,
135+
help="The _id of girder folder that the new folder will be created in. Defaults to user root."
136+
)
141137
def image_sequence(parent_folder, folder_name, path: Path, url, port):
138+
"""
139+
Create folder with FOLDER_NAME in PARENT_FOLDER and upload a set of images from PATH\n
140+
141+
FOLDER_NAME is a unique name for the folder to be created \n
142+
PATH is the the local path for the images to be uploaded
143+
"""
142144
gc = login(url, port)
143145
new_folder = create_folder(parent_folder, folder_name, gc)
144-
print("upload image sequence")
145146

146147
if new_folder:
147148
for file in path.iterdir():
@@ -164,8 +165,19 @@ def image_sequence(parent_folder, folder_name, path: Path, url, port):
164165

165166

166167
@upload.command()
167-
@upload_options
168+
@upload_arguments
169+
@click.option(
170+
"--parent-folder",
171+
type=str,
172+
help="The _id of girder folder that the new folder will be created in. Defaults to user root."
173+
)
168174
def video(parent_folder, folder_name, path, url, port):
175+
"""
176+
Create folder with FOLDER_NAME in PARENT_FOLDER and upload a video from PATH\n
177+
178+
FOLDER_NAME is a unique name for the folder to be created \n
179+
PATH is the the local path for the video to be uploaded
180+
"""
169181
gc = login(url, port)
170182
new_folder = create_folder(parent_folder, folder_name, gc)
171183
if new_folder:
@@ -185,8 +197,19 @@ def video(parent_folder, folder_name, path, url, port):
185197

186198

187199
@upload.command()
188-
@upload_options
200+
@upload_arguments
201+
@click.option(
202+
"--parent-folder",
203+
type=str,
204+
help="The _id of girder folder that the new folder will be created in. Defaults to user root."
205+
)
189206
def zip(parent_folder, folder_name, path, url, port):
207+
"""
208+
Create folder with FOLDER_NAME in PARENT_FOLDER and upload a zip file from PATH\n
209+
210+
FOLDER_NAME is a unique name for the folder to be created \n
211+
PATH is the the local path for the zip file to be uploaded
212+
"""
190213
gc = login(url, port)
191214
new_folder = create_folder(parent_folder, folder_name, gc)
192215
if new_folder:

0 commit comments

Comments
 (0)