ValidateCommand

Struct ValidateCommand 

Source
pub struct ValidateCommand {
    pub file: Option<String>,
    pub resolve: bool,
    pub check_lock: bool,
    pub sources: bool,
    pub paths: bool,
    pub format: OutputFormat,
    pub verbose: bool,
    pub quiet: bool,
    pub strict: bool,
    pub render: bool,
}
Expand description

Command to validate AGPM project configuration and dependencies.

This command performs comprehensive validation of a AGPM project, checking various aspects from basic manifest syntax to complex dependency resolution. It supports multiple validation levels and output formats for different use cases.

§Validation Strategy

The command performs validation in layers:

  1. Syntax Validation: TOML parsing and basic structure
  2. Semantic Validation: Required fields and references
  3. Extended Validation: Network and dependency checks (opt-in)
  4. Consistency Validation: Cross-file consistency checks

§Examples

use agpm_cli::cli::validate::{ValidateCommand, OutputFormat};

// Basic validation
let cmd = ValidateCommand {
    file: None,
    resolve: false,
    check_lock: false,
    sources: false,
    paths: false,
    format: OutputFormat::Text,
    verbose: false,
    quiet: false,
    strict: false,
    render: false,
};

// Comprehensive CI validation
let cmd = ValidateCommand {
    file: None,
    resolve: true,
    check_lock: true,
    sources: true,
    paths: true,
    format: OutputFormat::Json,
    verbose: false,
    quiet: true,
    strict: true,
    render: false,
};

Fields§

§file: Option<String>

Specific manifest file path to validate

If not provided, searches for agpm.toml in the current directory and parent directories. When specified, validates the exact file path.

§resolve: bool

Check if all dependencies can be resolved

Performs dependency resolution to verify that all dependencies defined in the manifest can be found and resolved to specific versions. This requires network access to check source repositories.

§check_lock: bool

Verify lockfile matches manifest

Compares the manifest dependencies with those recorded in the lockfile to identify inconsistencies. Warns if dependencies are missing from the lockfile or if extra entries exist.

§sources: bool

Check if all sources are accessible

Tests network connectivity to all source repositories defined in the manifest. This verifies that sources are reachable and accessible with current credentials.

§paths: bool

Check if local file paths exist

Validates that all local file dependencies (those without a source) point to existing files on the file system.

§format: OutputFormat

Output format: text or json

Controls the format of validation results:

  • text: Human-readable output with colors and formatting
  • json: Structured JSON output suitable for automation
§verbose: bool

Verbose output

Enables detailed output showing individual validation steps and additional diagnostic information.

§quiet: bool

Quiet output (minimal messages)

Suppresses informational messages, showing only errors and warnings. Useful for automated scripts and CI environments.

§strict: bool

Strict mode (treat warnings as errors)

In strict mode, any warnings will cause the validation to fail. This is useful for CI/CD pipelines where warnings should block deployment or integration.

§render: bool

Pre-render markdown templates and validate file references

Validates that all markdown resources can be successfully rendered with their template syntax, and that all file references within the markdown content point to existing files. This catches template errors and broken cross-references before installation. Requires a lockfile to build the template context.

When enabled:

  • Reads all markdown resources from worktrees/local paths
  • Attempts to render each with the current template context
  • Extracts and validates file references (markdown links and direct paths)
  • Reports syntax errors, missing variables, and broken file references
  • Returns non-zero exit code on validation failures

This is useful for:

  • Catching template errors in CI/CD before deployment
  • Validating template syntax during development
  • Ensuring referential integrity of documentation
  • Testing template rendering without modifying the filesystem

Implementations§

Source§

impl ValidateCommand

Source

pub async fn execute(self) -> Result<()>

Execute the validate command to check project configuration.

This method orchestrates the complete validation process, performing checks according to the specified options and outputting results in the requested format.

§Validation Process
  1. Manifest Loading: Locates and loads the manifest file
  2. Basic Validation: Checks syntax and required fields
  3. Extended Checks: Performs optional network and dependency checks
  4. Result Compilation: Aggregates all validation results
  5. Output Generation: Formats and displays results
  6. Exit Code: Returns success/failure based on results and strict mode
§Validation Ordering

Validations are performed in this order to provide early feedback:

  1. Manifest structure and syntax
  2. Dependency resolution (if --resolve)
  3. Source accessibility (if --sources)
  4. Local path validation (if --paths)
  5. Lockfile consistency (if --check-lock)
§Returns
  • Ok(()) if validation passes (or in strict mode, no warnings)
  • Err(anyhow::Error) if:
    • Manifest file is not found
    • Manifest has syntax errors
    • Critical validation failures occur
    • Strict mode is enabled and warnings are present
§Examples
use agpm_cli::cli::validate::{ValidateCommand, OutputFormat};

let cmd = ValidateCommand {
    file: None,
    resolve: true,
    check_lock: true,
    sources: false,
    paths: true,
    format: OutputFormat::Text,
    verbose: true,
    quiet: false,
    strict: false,
    render: false,
};
// cmd.execute().await?;
Source

pub async fn execute_with_manifest_path( self, manifest_path: Option<PathBuf>, ) -> Result<()>

Execute the validate command with an optional manifest path.

This method performs validation of the agpm.toml manifest file and optionally the associated lockfile. It can validate manifest syntax, source availability, and dependency resolution consistency.

§Arguments
  • manifest_path - Optional path to the agpm.toml file. If None, searches for agpm.toml in current directory and parent directories. If the command has a file field set, that takes precedence.
§Returns
  • Ok(()) if validation passes
  • Err(anyhow::Error) if validation fails or manifest is invalid
§Examples
use agpm_cli::cli::validate::ValidateCommand;
use std::path::PathBuf;

let cmd = ValidateCommand {
    file: None,
    check_lock: false,
    resolve: false,
    format: OutputFormat::Text,
    json: false,
    paths: false,
    fix: false,
};

cmd.execute_with_manifest_path(Some(PathBuf::from("./agpm.toml"))).await?;
Source

pub async fn execute_from_path(self, manifest_path: PathBuf) -> Result<()>

Executes validation using a specific manifest path

This method performs the same validation as execute() but accepts an explicit manifest path instead of searching for it.

§Arguments
  • manifest_path - Path to the manifest file to validate
§Returns

Returns Ok(()) if validation succeeds

§Errors

Returns an error if:

  • The manifest file doesn’t exist
  • The manifest has syntax errors
  • Sources are invalid or unreachable (with –resolve flag)
  • Dependencies have conflicts

Trait Implementations§

Source§

impl Args for ValidateCommand

Source§

fn group_id() -> Option<Id>

Report the ArgGroup::id for this set of arguments
Source§

fn augment_args<'b>(__clap_app: Command) -> Command

Append to Command so it can instantiate Self via FromArgMatches::from_arg_matches_mut Read more
Source§

fn augment_args_for_update<'b>(__clap_app: Command) -> Command

Append to Command so it can instantiate self via FromArgMatches::update_from_arg_matches_mut Read more
Source§

impl FromArgMatches for ValidateCommand

Source§

fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>

Instantiate Self from ArgMatches, parsing the arguments as needed. Read more
Source§

fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>

Instantiate Self from ArgMatches, parsing the arguments as needed. Read more
Source§

fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.
Source§

fn update_from_arg_matches_mut( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more