src/bin/proxmox-backup-manager.rs: cleanup output handling
This commit is contained in:
parent
4939255fb4
commit
ac3faaf5c0
@ -65,7 +65,7 @@ fn connect() -> Result<HttpClient, Error> {
|
|||||||
/// List configured remotes.
|
/// List configured remotes.
|
||||||
fn list_remotes(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
fn list_remotes(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||||
|
|
||||||
let output_format = param["output-format"].as_str().unwrap_or("text").to_owned();
|
let output_format = get_output_format(¶m);
|
||||||
|
|
||||||
let info = &api2::config::remote::API_METHOD_LIST_REMOTES;
|
let info = &api2::config::remote::API_METHOD_LIST_REMOTES;
|
||||||
let mut data = match info.handler {
|
let mut data = match info.handler {
|
||||||
@ -73,9 +73,7 @@ fn list_remotes(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value,
|
|||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let options = TableFormatOptions::new()
|
let options = default_table_format_options()
|
||||||
.noborder(false)
|
|
||||||
.noheader(false)
|
|
||||||
.column(ColumnConfig::new("name"))
|
.column(ColumnConfig::new("name"))
|
||||||
.column(ColumnConfig::new("host"))
|
.column(ColumnConfig::new("host"))
|
||||||
.column(ColumnConfig::new("userid"))
|
.column(ColumnConfig::new("userid"))
|
||||||
@ -152,7 +150,7 @@ fn datastore_commands() -> CommandLineInterface {
|
|||||||
/// Start garbage collection for a specific datastore.
|
/// Start garbage collection for a specific datastore.
|
||||||
async fn start_garbage_collection(param: Value) -> Result<Value, Error> {
|
async fn start_garbage_collection(param: Value) -> Result<Value, Error> {
|
||||||
|
|
||||||
let output_format = param["output-format"].as_str().unwrap_or("text").to_owned();
|
let output_format = get_output_format(¶m);
|
||||||
|
|
||||||
let store = tools::required_string_param(¶m, "store")?;
|
let store = tools::required_string_param(¶m, "store")?;
|
||||||
|
|
||||||
@ -183,7 +181,7 @@ async fn start_garbage_collection(param: Value) -> Result<Value, Error> {
|
|||||||
/// Show garbage collection status for a specific datastore.
|
/// Show garbage collection status for a specific datastore.
|
||||||
async fn garbage_collection_status(param: Value) -> Result<Value, Error> {
|
async fn garbage_collection_status(param: Value) -> Result<Value, Error> {
|
||||||
|
|
||||||
let output_format = param["output-format"].as_str().unwrap_or("text").to_owned();
|
let output_format = get_output_format(¶m);
|
||||||
|
|
||||||
let store = tools::required_string_param(¶m, "store")?;
|
let store = tools::required_string_param(¶m, "store")?;
|
||||||
|
|
||||||
@ -195,9 +193,7 @@ async fn garbage_collection_status(param: Value) -> Result<Value, Error> {
|
|||||||
let mut data = result["data"].take();
|
let mut data = result["data"].take();
|
||||||
let schema = api2::admin::datastore::API_RETURN_SCHEMA_GARBAGE_COLLECTION_STATUS;
|
let schema = api2::admin::datastore::API_RETURN_SCHEMA_GARBAGE_COLLECTION_STATUS;
|
||||||
|
|
||||||
let options = TableFormatOptions::new()
|
let options = default_table_format_options();
|
||||||
.noborder(false)
|
|
||||||
.noheader(false);
|
|
||||||
|
|
||||||
format_and_print_result_full(&mut data, schema, &output_format, &options);
|
format_and_print_result_full(&mut data, schema, &output_format, &options);
|
||||||
|
|
||||||
@ -247,7 +243,7 @@ fn garbage_collection_commands() -> CommandLineInterface {
|
|||||||
/// List running server tasks.
|
/// List running server tasks.
|
||||||
async fn task_list(param: Value) -> Result<Value, Error> {
|
async fn task_list(param: Value) -> Result<Value, Error> {
|
||||||
|
|
||||||
let output_format = param["output-format"].as_str().unwrap_or("text").to_owned();
|
let output_format = get_output_format(¶m);
|
||||||
|
|
||||||
let client = connect()?;
|
let client = connect()?;
|
||||||
|
|
||||||
@ -263,9 +259,7 @@ async fn task_list(param: Value) -> Result<Value, Error> {
|
|||||||
let mut data = result["data"].take();
|
let mut data = result["data"].take();
|
||||||
let schema = api2::node::tasks::API_RETURN_SCHEMA_LIST_TASKS;
|
let schema = api2::node::tasks::API_RETURN_SCHEMA_LIST_TASKS;
|
||||||
|
|
||||||
let options = TableFormatOptions::new()
|
let options = default_table_format_options()
|
||||||
.noborder(false)
|
|
||||||
.noheader(false)
|
|
||||||
.column(ColumnConfig::new("starttime").right_align(false).renderer(tools::format::render_epoch))
|
.column(ColumnConfig::new("starttime").right_align(false).renderer(tools::format::render_epoch))
|
||||||
.column(ColumnConfig::new("endtime").right_align(false).renderer(tools::format::render_epoch))
|
.column(ColumnConfig::new("endtime").right_align(false).renderer(tools::format::render_epoch))
|
||||||
.column(ColumnConfig::new("upid"))
|
.column(ColumnConfig::new("upid"))
|
||||||
@ -458,10 +452,10 @@ async fn pull_datastore(
|
|||||||
remote_store: String,
|
remote_store: String,
|
||||||
local_store: String,
|
local_store: String,
|
||||||
delete: Option<bool>,
|
delete: Option<bool>,
|
||||||
output_format: Option<String>,
|
param: Value,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let output_format = output_format.unwrap_or("text".to_string());
|
let output_format = get_output_format(¶m);
|
||||||
|
|
||||||
let mut client = connect()?;
|
let mut client = connect()?;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user