forked from proxmox-mirrors/proxmox
schema: clippy fixups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
17805f9791
commit
9079afc831
@ -5,7 +5,7 @@ use anyhow::{bail, Error};
|
|||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
/// Enumerate different styles to display parameters/properties.
|
/// Enumerate different styles to display parameters/properties.
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||||
pub enum ParameterDisplayStyle {
|
pub enum ParameterDisplayStyle {
|
||||||
/// Used for properties in configuration files: ``key:``
|
/// Used for properties in configuration files: ``key:``
|
||||||
Config,
|
Config,
|
||||||
@ -18,7 +18,7 @@ pub enum ParameterDisplayStyle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// CLI usage information format.
|
/// CLI usage information format.
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||||
pub enum DocumentationFormat {
|
pub enum DocumentationFormat {
|
||||||
/// Text, command line only (one line).
|
/// Text, command line only (one line).
|
||||||
Short,
|
Short,
|
||||||
@ -122,7 +122,7 @@ pub fn dump_properties(
|
|||||||
|
|
||||||
if !indent.is_empty() {
|
if !indent.is_empty() {
|
||||||
param_descr = format!("{}{}", indent, param_descr); // indent first line
|
param_descr = format!("{}{}", indent, param_descr); // indent first line
|
||||||
param_descr = param_descr.replace("\n", &format!("\n{}", indent)); // indent rest
|
param_descr = param_descr.replace('\n', &format!("\n{}", indent)); // indent rest
|
||||||
}
|
}
|
||||||
|
|
||||||
if style == ParameterDisplayStyle::Config {
|
if style == ParameterDisplayStyle::Config {
|
||||||
@ -398,7 +398,10 @@ pub fn dump_enum_properties(schema: &Schema) -> Result<String, Error> {
|
|||||||
}) = schema
|
}) = schema
|
||||||
{
|
{
|
||||||
for item in variants.iter() {
|
for item in variants.iter() {
|
||||||
res.push_str(&format!(":``{}``: ", item.value));
|
use std::fmt::Write;
|
||||||
|
|
||||||
|
let _ = write!(res, ":``{}``: ", item.value);
|
||||||
|
//res.push_str(&format!(":``{}``: ", item.value));
|
||||||
let descr = wrap_text("", " ", item.description, 80);
|
let descr = wrap_text("", " ", item.description, 80);
|
||||||
res.push_str(&descr);
|
res.push_str(&descr);
|
||||||
res.push('\n');
|
res.push('\n');
|
||||||
@ -410,6 +413,8 @@ pub fn dump_enum_properties(schema: &Schema) -> Result<String, Error> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn dump_api_return_schema(returns: &ReturnType, style: ParameterDisplayStyle) -> String {
|
pub fn dump_api_return_schema(returns: &ReturnType, style: ParameterDisplayStyle) -> String {
|
||||||
|
use std::fmt::Write;
|
||||||
|
|
||||||
let schema = &returns.schema;
|
let schema = &returns.schema;
|
||||||
|
|
||||||
let mut res = if returns.optional {
|
let mut res = if returns.optional {
|
||||||
@ -419,7 +424,8 @@ pub fn dump_api_return_schema(returns: &ReturnType, style: ParameterDisplayStyle
|
|||||||
};
|
};
|
||||||
|
|
||||||
let type_text = get_schema_type_text(schema, style);
|
let type_text = get_schema_type_text(schema, style);
|
||||||
res.push_str(&format!("**{}**\n\n", type_text));
|
//res.push_str(&format!("**{}**\n\n", type_text));
|
||||||
|
let _ = write!(res, "**{}**\n\n", type_text);
|
||||||
|
|
||||||
match schema {
|
match schema {
|
||||||
Schema::Null => {
|
Schema::Null => {
|
||||||
|
@ -92,6 +92,8 @@ impl ParameterError {
|
|||||||
|
|
||||||
impl fmt::Display for ParameterError {
|
impl fmt::Display for ParameterError {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
use std::fmt::Write;
|
||||||
|
|
||||||
let mut msg = String::new();
|
let mut msg = String::new();
|
||||||
|
|
||||||
if !self.is_empty() {
|
if !self.is_empty() {
|
||||||
@ -99,7 +101,7 @@ impl fmt::Display for ParameterError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (name, err) in self.error_list.iter() {
|
for (name, err) in self.error_list.iter() {
|
||||||
msg.push_str(&format!("parameter '{}': {}\n", name, err));
|
let _ = writeln!(msg, "parameter '{}': {}", name, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
write!(f, "{}", msg)
|
write!(f, "{}", msg)
|
||||||
|
Loading…
Reference in New Issue
Block a user