Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

address help issues in the expanded reset command #182

Merged
merged 2 commits into from
Oct 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 10 additions & 19 deletions src/cli/onefuzz/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1290,10 +1290,10 @@ def config(

return data

def _user_confirmation(self, message: List[str]) -> bool:
def _user_confirmation(self, message: str) -> bool:
answer: Optional[str] = None
while answer not in ["y", "n"]:
answer = input(" ".join(message)).strip()
answer = input(message).strip()

if answer == "n":
self.logger.info("not stopping")
Expand Down Expand Up @@ -1389,19 +1389,6 @@ def reset(
:param bool tasks: Stop all tasks.
:param bool yes: Ignoring to specify "y" in prompt.
"""
delete_options = [
containers,
jobs,
pools,
notifications,
repros,
scalesets,
tasks,
]
arguments = [everything]
arguments.extend(delete_options)
if not any(arguments):
jobs, notifications, repros, tasks = True, True, True, True

if everything:
containers, jobs, pools, notifications, repros, scalesets, tasks = (
Expand All @@ -1413,10 +1400,13 @@ def reset(
True,
True,
)
elif not any(
[containers, jobs, pools, notifications, repros, scalesets, tasks]
):
jobs, notifications, repros, tasks = True, True, True, True

if containers and not (tasks or jobs):
print("Use --jobs or --tasks with containers")
return
raise Exception("Resetting containers requires resetting jobs or tasks")

to_delete = []
argument_str = {
Expand All @@ -1431,8 +1421,9 @@ def reset(
for k, v in locals().items():
if k in argument_str and v:
to_delete.append(k)
message = ["Confirm stopping %s " % (", ".join(to_delete))]
message += ["(specify y or n): "]
message = "Confirm stopping %s (specify y or n): " % (
", ".join(sorted(to_delete))
)
if not yes and not self._user_confirmation(message):
return

Expand Down
2 changes: 2 additions & 0 deletions src/cli/onefuzz/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,8 @@ def parse_tuple(data: str) -> Tuple[Any, ...]:
class_result = self.parse_annotation_class(name, annotation, default)
if class_result is not None:
result.update(class_result)
if help_doc and result["help"] != help_doc:
result["help"] = "%s %s" % (help_doc, result["help"])
return result

# isinstance type signatures doesn't support TypeVar
Expand Down