Skip to content

Commit ade39ec

Browse files
committed
Added generator
1 parent 6e2084e commit ade39ec

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

scripts/cli-wrapper-gen.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def get_description(item):
100100

101101

102102
base_path = sys.argv[1]
103-
with open("%s/scripts/cli-reference.yaml" % base_path) as stream:
103+
with open("%s/cli-reference.yaml" % base_path) as stream:
104104
try:
105105
reference = yaml.safe_load(stream)
106106

@@ -114,7 +114,7 @@ def get_description(item):
114114
subcommand["arguments"] = arguments
115115
subcommand["parameters"] = parameters
116116

117-
templateLoader = jinja2.FileSystemLoader(searchpath="%s/scripts/templates/" % base_path)
117+
templateLoader = jinja2.FileSystemLoader(searchpath="%s/scripts/" % base_path)
118118
environment = jinja2.Environment(loader=templateLoader)
119119

120120
environment.filters["no_newline"] = no_newline
@@ -129,7 +129,7 @@ def get_description(item):
129129

130130
template = environment.get_template("cli-wrapper.jinja2")
131131
output = template.render({"commands": reference["commands"]})
132-
with open("%s/cli.py" % base_path, "t+w") as target:
132+
with open("%s/simplyblock_cli/cli.py" % base_path, "t+w") as target:
133133
target.write(output)
134134

135135
except yaml.YAMLError as exc:

scripts/generate.sh

100644100755
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
PYTHON="$(command -v python)"
4+
if [[ "${PYTHON}" == "" ]]; then
5+
PYTHON="$(comamnd -v python3)"
6+
fi
7+
8+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
9+
${PYTHON} "${SCRIPT_DIR}/cli-wrapper-gen.py" "${SCRIPT_DIR}/.."

0 commit comments

Comments
 (0)