debug: api ls: make path optional and default to "/"

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2021-09-21 15:11:36 +02:00
parent f7885eb263
commit c25ea25f0a

View File

@ -424,6 +424,7 @@ async fn get_api_children(
path: { path: {
type: String, type: String,
description: "API path.", description: "API path.",
optional: true,
}, },
"output-format": { "output-format": {
schema: OUTPUT_FORMAT, schema: OUTPUT_FORMAT,
@ -433,7 +434,7 @@ async fn get_api_children(
}, },
)] )]
/// Get API usage information for <path> /// Get API usage information for <path>
async fn ls(path: String, mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<(), Error> { async fn ls(path: Option<String>, mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<(), Error> {
let output_format = extract_output_format(&mut param); let output_format = extract_output_format(&mut param);
let options = TableFormatOptions::new() let options = TableFormatOptions::new()
@ -441,7 +442,7 @@ async fn ls(path: String, mut param: Value, rpcenv: &mut dyn RpcEnvironment) ->
.noheader(true) .noheader(true)
.sortby("name", false); .sortby("name", false);
let res = get_api_children(path, rpcenv).await?; let res = get_api_children(path.unwrap_or(String::from("/")), rpcenv).await?;
format_and_print_result_full( format_and_print_result_full(
&mut serde_json::to_value(res)?, &mut serde_json::to_value(res)?,