Skip to content

Commit cdd14e4

Browse files
authored
Merge pull request #588 from willcl-ark/apidoc-robust
2 parents 6afb540 + 50d724e commit cdd14e4

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

docs/warnet.md

+16-5
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Show the logs of a pod
4848
options:
4949
| name | type | required | default |
5050
|----------|--------|------------|-----------|
51-
| pod_name | String | | |
51+
| pod_name | String | | "" |
5252
| follow | Bool | | False |
5353

5454
### `warnet new`
@@ -72,6 +72,17 @@ options:
7272
Setup warnet
7373

7474

75+
### `warnet snapshot`
76+
Create a snapshot of a tank's Bitcoin data or snapshot all tanks
77+
78+
options:
79+
| name | type | required | default |
80+
|--------------|--------|------------|--------------------|
81+
| tank_name | String | | |
82+
| snapshot_all | Bool | | False |
83+
| output | Path | | ./warnet-snapshots |
84+
| filter | String | | |
85+
7586
### `warnet status`
7687
Display the unified status of the Warnet network and active scenarios
7788

@@ -138,16 +149,16 @@ options:
138149

139150
### `warnet graph import-json`
140151
Create a cycle graph with nodes imported from lnd `describegraph` JSON file,
141-
and additionally include 7 extra random outbounds per node. Include lightning
142-
channels and their policies as well.
143-
Returns XML file as string with or without --outfile option.
152+
and additionally include 7 extra random outbounds per node. Include lightning
153+
channels and their policies as well.
154+
Returns XML file as string with or without --outfile option.
144155

145156

146157
## Image
147158

148159
### `warnet image build`
149160
Build bitcoind and bitcoin-cli from \<repo> at \<commit_sha> with the specified \<tags>.
150-
Optionally deploy to remote registry using --action=push, otherwise image is loaded to local registry.
161+
Optionally deploy to remote registry using --action=push, otherwise image is loaded to local registry.
151162

152163
options:
153164
| name | type | required | default |

resources/scripts/apidocs.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@ def print_cmd(cmd, super=""):
2626
p["name"],
2727
p["type"]["param_type"] if p["type"]["param_type"] != "Unprocessed" else "String",
2828
"yes" if p["required"] else "",
29-
'"' + p["default"] + '"'
30-
if p["default"] and p["type"]["param_type"] == "String"
31-
else Path(p["default"]).relative_to(Path.cwd())
32-
if p["default"] and p["type"]["param_type"] == "Path"
33-
else p["default"],
29+
format_default_value(p["default"], p["type"]["param_type"]),
3430
]
3531
for p in cmd["params"]
3632
if p["name"] != "help"
@@ -39,6 +35,16 @@ def print_cmd(cmd, super=""):
3935
doc += "\n\n"
4036

4137

38+
def format_default_value(default, param_type):
39+
if default is None:
40+
return ""
41+
if param_type == "String":
42+
return f'"{default}"'
43+
if param_type == "Path":
44+
return str(default)
45+
return default
46+
47+
4248
with Context(cli) as ctx:
4349
info = ctx.to_info_dict()
4450
# root-level commands first

0 commit comments

Comments
 (0)