-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathdev.py
More file actions
87 lines (68 loc) · 2.31 KB
/
dev.py
File metadata and controls
87 lines (68 loc) · 2.31 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import os
from cfengine_cli.masterfiles.generate_release_information import (
generate_release_information_impl,
)
from cfengine_cli.utils import UserError
from cfengine_cli.deptool import (
update_dependency_tables as _update_dependency_tables,
print_release_dependency_tables,
)
from cfengine_cli.docs import update_docs, check_docs
def generate_release_information_command(
omit_download=False, check=False, min_version=None
):
generate_release_information_impl(omit_download, check, min_version)
return 0
def _continue_prompt() -> bool:
answer = None
while answer not in ("y", "n", "yes", "no"):
print("Continue? (Y/n): ", end="")
answer = input().strip().lower()
return answer in ("y", "yes")
def _expect_repo(repo) -> bool:
cwd = os.getcwd()
if cwd.endswith(repo):
return True
print(f"Note: This command is intended to be run in the {repo} repo")
print(f" https://github.com/cfengine/{repo}")
answer = _continue_prompt()
return answer
def update_dependency_tables() -> int:
answer = _expect_repo("buildscripts")
if answer:
return _update_dependency_tables()
return 1
def print_dependency_tables(args) -> int:
versions = args.versions
answer = _expect_repo("buildscripts")
if answer:
return print_release_dependency_tables(versions)
return 1
def format_docs() -> int:
answer = _expect_repo("documentation")
if answer:
return update_docs()
return 1
def lint_docs() -> int:
answer = _expect_repo("documentation")
if answer:
return check_docs()
return 1
def generate_release_information() -> int:
answer = _expect_repo("release-information")
if answer:
generate_release_information_command()
return 0
return 1
def dispatch_dev_subcommand(subcommand, args) -> int:
if subcommand == "update-dependency-tables":
return update_dependency_tables()
if subcommand == "print-dependency-tables":
return print_dependency_tables(args)
if subcommand == "format-docs":
return format_docs()
if subcommand == "lint-docs":
return lint_docs()
if subcommand == "generate-release-information":
return generate_release_information()
raise UserError("Invalid cfengine dev subcommand - " + subcommand)