oxvg 0.0.7

Vector image toolchain.
Documentation
//! Traits and types for handling the command line arguments for OXVG.
use std::future::Future;

use clap::{Parser, Subcommand};

use crate::{
    commands::{Action, Format, JSX, Lint, Optimise},
    config::Config,
};

/// A type for a runnable command.
pub trait RunCommand {
    /// Runs the command with the specified config.
    ///
    /// # Errors
    ///
    /// If any part of the lifecycle fails
    /// * Fails to read or parse any files
    /// * Fails to write or serialize to any files
    fn run(self, config: Config) -> impl Future<Output = anyhow::Result<()>> + Send;
}

#[derive(Parser)]
#[clap(
    bin_name = "oxvg",
    name = "oxvg",
    author,
    version,
    about = "Your versatile vector-graphics toolchain",
    long_about = None
)]
/// Args that can be provided when running OXVG via the command line.
pub struct Args {
    #[clap(subcommand)]
    /// The subcommands for OXVG
    pub command: Command,
}

#[derive(Subcommand)]
/// The subcommands for OXVG
pub enum Command {
    /// Optimise SVG documents
    #[clap(alias = "optimize")]
    Optimise(Optimise),
    /// Format SVG documents
    ///
    /// This is an alias for `oxvg optimise --extends none` with default options sensible
    /// for formatting
    Format(Format),
    /// Lint SVG documents
    #[command(subcommand)]
    Lint(Lint),
    /// Transform SVG documents
    #[clap(alias = "actions")]
    Action(Action),
    /// Convert SVG documents to JSX
    JSX(JSX),
    #[cfg(feature = "visual-regression")]
    /// Visual regression testing for OXVG outputs
    VisualRegression(crate::commands::VisualRegression),
    #[cfg(feature = "render")]
    /// Render SVG documents
    Render(crate::commands::Render),
}