Skip to content

Commit

Permalink
Merge pull request #588 from willcl-ark/apidoc-robust
Browse files Browse the repository at this point in the history
  • Loading branch information
willcl-ark authored Sep 12, 2024
2 parents 6afb540 + 50d724e commit cdd14e4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
21 changes: 16 additions & 5 deletions docs/warnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Show the logs of a pod
options:
| name | type | required | default |
|----------|--------|------------|-----------|
| pod_name | String | | |
| pod_name | String | | "" |
| follow | Bool | | False |

### `warnet new`
Expand All @@ -72,6 +72,17 @@ options:
Setup warnet


### `warnet snapshot`
Create a snapshot of a tank's Bitcoin data or snapshot all tanks

options:
| name | type | required | default |
|--------------|--------|------------|--------------------|
| tank_name | String | | |
| snapshot_all | Bool | | False |
| output | Path | | ./warnet-snapshots |
| filter | String | | |

### `warnet status`
Display the unified status of the Warnet network and active scenarios

Expand Down Expand Up @@ -138,16 +149,16 @@ options:

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


## Image

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

options:
| name | type | required | default |
Expand Down
16 changes: 11 additions & 5 deletions resources/scripts/apidocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ def print_cmd(cmd, super=""):
p["name"],
p["type"]["param_type"] if p["type"]["param_type"] != "Unprocessed" else "String",
"yes" if p["required"] else "",
'"' + p["default"] + '"'
if p["default"] and p["type"]["param_type"] == "String"
else Path(p["default"]).relative_to(Path.cwd())
if p["default"] and p["type"]["param_type"] == "Path"
else p["default"],
format_default_value(p["default"], p["type"]["param_type"]),
]
for p in cmd["params"]
if p["name"] != "help"
Expand All @@ -39,6 +35,16 @@ def print_cmd(cmd, super=""):
doc += "\n\n"


def format_default_value(default, param_type):
if default is None:
return ""
if param_type == "String":
return f'"{default}"'
if param_type == "Path":
return str(default)
return default


with Context(cli) as ctx:
info = ctx.to_info_dict()
# root-level commands first
Expand Down

0 comments on commit cdd14e4

Please sign in to comment.