Skip to content

Commit a99ea55

Browse files
authored
Project listing improvement (#67)
* change question type if a lot of projects are present * version bump * oops
1 parent 7f3b131 commit a99ea55

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed
Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
from typing import List
22

33
from cirro.api.models.project import Project
4-
from cirro.cli.interactive.utils import prompt_wrapper
4+
from cirro.cli.interactive.utils import ask
55

66

77
def ask_project(projects: List[Project], input_value: str) -> str:
8-
project_names = [project.name for project in projects]
9-
project_prompt = {
10-
'type': 'list',
11-
'name': 'project',
12-
'message': 'What project is this dataset associated with?',
13-
'choices': project_names,
14-
'default': input_value if input_value in project_names else None
15-
}
16-
answers = prompt_wrapper(project_prompt)
17-
return answers['project']
8+
project_names = sorted([project.name for project in projects])
9+
if len(project_names) <= 10:
10+
return ask(
11+
'select',
12+
'What project is this dataset associated with?',
13+
choices=project_names,
14+
default=input_value if input_value in project_names else None
15+
)
16+
else:
17+
return ask(
18+
'autocomplete',
19+
'What project is this dataset associated with? (use TAB to display options)',
20+
choices=project_names,
21+
default=input_value if input_value in project_names else ''
22+
)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "cirro"
3-
version = "0.6.9"
3+
version = "0.6.10"
44
description = "CLI tool and SDK for interacting with the Cirro platform"
55
authors = ["Fred Hutch <[email protected]>"]
66
license = "MIT"

0 commit comments

Comments
 (0)