router: cli: add OutputFormat enum api type
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
dd36fec23d
commit
034bb9cdda
@ -22,8 +22,9 @@ http = { workspace = true, optional = true }
|
||||
hyper = { workspace = true, features = [ "full" ], optional = true }
|
||||
nix.workspace = true
|
||||
percent-encoding.workspace = true
|
||||
serde = { workspace = true, features = [ "derive" ] }
|
||||
serde_json.workspace = true
|
||||
serde.workspace = true
|
||||
serde_plain.workspace = true
|
||||
unicode-width ="0.1.8"
|
||||
regex = { workspace = true, optional = true }
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
use anyhow::{bail, format_err, Error};
|
||||
use serde_json::Value;
|
||||
use std::cell::RefCell;
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::{bail, format_err, Error};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
|
||||
use proxmox_schema::format::DocumentationFormat;
|
||||
use proxmox_schema::*;
|
||||
|
||||
@ -14,6 +16,25 @@ use super::{
|
||||
};
|
||||
use crate::{ApiFuture, ApiHandler, ApiMethod, RpcEnvironment};
|
||||
|
||||
/// Command line output format.
|
||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub enum OutputFormat {
|
||||
/// Command specific plain text output.
|
||||
#[default]
|
||||
Text,
|
||||
/// Single line JSON output.
|
||||
Json,
|
||||
/// Prettified JSON output.
|
||||
JsonPretty,
|
||||
}
|
||||
serde_plain::derive_display_from_serialize!(OutputFormat);
|
||||
serde_plain::derive_fromstr_from_deserialize!(OutputFormat);
|
||||
|
||||
impl ApiType for OutputFormat {
|
||||
const API_SCHEMA: Schema = OUTPUT_FORMAT;
|
||||
}
|
||||
|
||||
/// Schema definition for ``--output-format`` parameter.
|
||||
///
|
||||
/// - ``text``: command specific text format.
|
||||
|
Loading…
Reference in New Issue
Block a user