Module for modifying and printing the state file.
remove_state(state_object_name)
Removes state file.
Source code in dapla_team_cli/pr/state/state_commands.py
27
28
29
30
31
32
33
34
35
36
37
38 | def remove_state(state_object_name: StateObjectName) -> None:
"""Removes state file."""
if state_object_name is None:
sys.exit(0)
confirm = questionary.confirm(f"Are you sure you want to delete the statefile {state_object_name}?").ask()
if not confirm:
sys.exit(1)
blob = state_object_handler.get_bucket().blob(state_object_name)
blob.delete()
print("State file deleted")
|
show_state(state, repo_name=None)
Print the state.
Source code in dapla_team_cli/pr/state/state_commands.py
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64 | @batch_handler
def show_state(state: State, repo_name: Optional[str] = None) -> None: # noqa: C901, E261
"""Print the state."""
table = _initialize_table()
if repo_name is not None:
# The user wishes to print one specific repo
if repo_name not in state.repos.keys():
print("The provided repository ({name}) does not exist in the selected state file.")
sys.exit(0)
repo_list = [repo_name]
else:
repo_list = list(state.repos.keys())
for name in repo_list:
repo = state.get_repo_state(name)
row: List[Union[str, Text]] = [repo.name]
for value in repo.workflow.dict().values():
row.append(_get_workflow_cell(value))
for key, value in repo.pr.dict().items():
row.append(_get_pr_metadata_cell(key, value))
table.add_row(*row)
print(table)
|