rudof_cli 0.3.18

RDF and Knowledge Graphs processing tool
use std::path::PathBuf;

use crate::cli::parser::CommonArgsAll;
use crate::cli::wrappers::{
    DataFormatCli, DataReaderModeCli, RecursionSemanticsCli, ResultValidationFormatCli, ShExFormatCli,
    ShaclValidationModeCli, ShapeMapFormatCli, ValidationModeCli, ValidationSortByModeCli,
};
use clap::Args;
use rudof_lib::formats::InputSpec;

/// Arguments for the `validate` command
#[derive(Debug, Clone, Args)]
pub struct ValidateArgs {
    #[clap(value_parser = clap::value_parser!(InputSpec))]
    pub data: Vec<InputSpec>,

    #[arg(short = 'M', long = "mode",
        value_name = "MODE",
        ignore_case = true,
        help = "Validation mode (ShEx or SHACL)",
        default_value_t = ValidationModeCli::ShEx
    )]
    pub validation_mode: ValidationModeCli,

    #[arg(
        short = 's',
        long = "schema",
        value_name = "INPUT",
        help = "Schema used for validatio, FILE, URI or - for stdin"
    )]
    pub schema: Option<InputSpec>,

    #[arg(
        short = 'f',
        long = "schema-format",
        ignore_case = true,
        value_name = "FORMAT",
        help = "Schema format",
        default_value_t = ShExFormatCli::ShExC
    )]
    pub schema_format: ShExFormatCli,

    #[arg(
        short = 'm',
        long = "shapemap",
        value_name = "INPUT",
        help = "ShapeMap used for validation, FILE, URI or - for stdin"
    )]
    pub shapemap: Option<InputSpec>,

    #[arg(
        long = "shapemap-format",
        value_name = "FORMAT",
        ignore_case = true,
        help = "ShapeMap format",
        default_value_t = ShapeMapFormatCli::Compact,
    )]
    pub shapemap_format: ShapeMapFormatCli,

    #[arg(long = "base-data", value_name = "IRI", help = "Base IRI for data")]
    pub base_data: Option<String>,

    #[arg(long = "base-schema", value_name = "IRI", help = "Base IRI for Schema")]
    pub base_schema: Option<String>,

    #[arg(
        long = "sort_by",
        value_name = "SORT_MODE",
        ignore_case = true,
        help = "Sort result by (default = node)",
        default_value_t = ValidationSortByModeCli::Node,
        value_enum
    )]
    pub sort_by: ValidationSortByModeCli,

    #[arg(short = 'n', long = "node", value_name = "NODE", help = "Node to validate")]
    pub node: Option<String>,

    #[arg(
        short = 'l',
        long = "shape-label",
        value_name = "LABEL",
        help = "shape label (default = START)",
        group = "node_shape"
    )]
    pub shape: Option<String>,

    #[arg(
        short = 't',
        long = "data-format",
        value_name = "FORMAT",
        ignore_case = true,
        help = "RDF Data format (default = turtle)",
        default_value_t = DataFormatCli::Turtle
    )]
    pub data_format: DataFormatCli,

    #[arg(
        long = "max-steps",
        value_name = "NUMBER",
        help = "max steps to run during validation",
        default_value_t = 1000
    )]
    pub max_steps: usize,

    #[arg(
        short = 'S',
        long = "shacl-mode",
        value_name = "MODE",
        ignore_case = true,
        help = "SHACL validation mode (default = native)",
        default_value_t = ShaclValidationModeCli::Native,
        value_enum
    )]
    pub shacl_validation_mode: ShaclValidationModeCli,

    #[arg(
        long = "reader-mode",
        value_name = "MODE", help = "RDF Reader mode",
        ignore_case = true,
        default_value_t = DataReaderModeCli::Strict,
        value_enum
    )]
    pub reader_mode: DataReaderModeCli,

    #[arg(
        short = 'r',
        long = "result-format",
        ignore_case = true,
        value_name = "FORMAT", help = "Ouput result format, default = compact",
        default_value_t = ResultValidationFormatCli::Compact
    )]
    pub result_format: ResultValidationFormatCli,

    #[arg(long = "map-state", value_name = "FILE", help = "MapState file name")]
    pub map_state: Option<PathBuf>,

    #[arg(
        long = "show-intermediate-results",
        help = "Print each (node, shape) result as soon as it's computed, instead of only the final report"
    )]
    pub show_intermediate_results: bool,

    #[arg(
        long = "no-errors",
        help = "SHACL only: don't retain violations in the validation report (default: violations are kept)"
    )]
    pub no_errors: bool,

    #[arg(
        long = "with-evidences",
        help = "SHACL only: also retain evidence for why (node, shape) pairs conform (default: not kept)"
    )]
    pub with_evidences: bool,

    #[arg(
        long = "evidences-shapes-only",
        help = "SHACL only, with --with-evidences: keep only the per-shape summary evidence, \
                dropping the finer per-constraint-component evidence (default: keep everything)"
    )]
    pub evidences_shapes_only: bool,

    #[arg(
        long = "recursion-semantics",
        value_name = "MODE",
        ignore_case = true,
        value_enum,
        help = "SHACL only: whether to accept a shapes graph with a recursive (cyclic) shape \
                reference, and how to resolve it: `cautious` (default) accepts it and assumes \
                a node caught in the cycle does NOT conform unless proven otherwise; `brave` \
                accepts it and assumes such a node DOES conform as long as that's \
                self-consistent; `none` rejects it outright"
    )]
    pub recursion_semantics: Option<RecursionSemanticsCli>,

    #[command(flatten)]
    pub common: CommonArgsAll,
}