Skip to content
Open

Docs #56

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use clap::Parser;
use xml_schema_generator::{Options, SortBy};

/// collection of command line arguments
/// Command-line arguments for the XML schema generator
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
pub struct Args {
Expand All @@ -21,7 +21,7 @@ pub struct Args {
pub output_path: Option<String>,
}

/// supported parser variants
/// Sorting options for command-line interface
#[derive(clap::ValueEnum, Clone, Default, Debug)]
pub enum SortByArg {
/// the order remains as found in document
Expand All @@ -31,7 +31,17 @@ pub enum SortByArg {
Name,
}

/// Converts command-line sort argument to internal `SortBy` enum
impl From<SortByArg> for SortBy {
/// Converts a `SortByArg` to `SortBy`
///
/// # Arguments
///
/// * `val` - The command-line sort argument
///
/// # Returns
///
/// The corresponding `SortBy` variant
fn from(val: SortByArg) -> Self {
match val {
SortByArg::Unsorted => SortBy::Unsorted,
Expand All @@ -40,16 +50,25 @@ impl From<SortByArg> for SortBy {
}
}

/// supported parser variants
/// Supported XML parser libraries for code generation
#[derive(clap::ValueEnum, Clone, Default, Debug)]
pub enum ParserArg {
#[default]
QuickXmlDe,
SerdeXmlRs,
}

/// simplify conversion of argument into parsing options
/// Converts command-line parser argument to `Options` configuration
impl From<ParserArg> for Options {
/// Converts a `ParserArg` to `Options`
///
/// # Arguments
///
/// * `val` - The command-line parser argument
///
/// # Returns
///
/// `Options` configured for the selected parser
fn from(val: ParserArg) -> Self {
match val {
ParserArg::QuickXmlDe => Options::quick_xml_de(),
Expand Down
Loading
Loading