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:
- Syntax Validation: TOML parsing and basic structure
- Semantic Validation: Required fields and references
- Extended Validation: Network and dependency checks (opt-in)
- 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: boolCheck 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: boolVerify 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: boolCheck 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: boolCheck if local file paths exist
Validates that all local file dependencies (those without a source) point to existing files on the file system.
format: OutputFormatOutput format: text or json
Controls the format of validation results:
text: Human-readable output with colors and formattingjson: Structured JSON output suitable for automation
verbose: boolVerbose output
Enables detailed output showing individual validation steps and additional diagnostic information.
quiet: boolQuiet output (minimal messages)
Suppresses informational messages, showing only errors and warnings. Useful for automated scripts and CI environments.
strict: boolStrict 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: boolPre-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
impl ValidateCommand
Sourcepub async fn execute(self) -> Result<()>
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
- Manifest Loading: Locates and loads the manifest file
- Basic Validation: Checks syntax and required fields
- Extended Checks: Performs optional network and dependency checks
- Result Compilation: Aggregates all validation results
- Output Generation: Formats and displays results
- Exit Code: Returns success/failure based on results and strict mode
§Validation Ordering
Validations are performed in this order to provide early feedback:
- Manifest structure and syntax
- Dependency resolution (if
--resolve) - Source accessibility (if
--sources) - Local path validation (if
--paths) - 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?;Sourcepub async fn execute_with_manifest_path(
self,
manifest_path: Option<PathBuf>,
) -> Result<()>
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 afilefield set, that takes precedence.
§Returns
Ok(())if validation passesErr(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?;Sourcepub async fn execute_from_path(self, manifest_path: PathBuf) -> Result<()>
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
impl Args for ValidateCommand
Source§fn augment_args<'b>(__clap_app: Command) -> Command
fn augment_args<'b>(__clap_app: Command) -> Command
Source§fn augment_args_for_update<'b>(__clap_app: Command) -> Command
fn augment_args_for_update<'b>(__clap_app: Command) -> Command
Command so it can instantiate self via
FromArgMatches::update_from_arg_matches_mut Read moreSource§impl FromArgMatches for ValidateCommand
impl FromArgMatches for ValidateCommand
Source§fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
Source§fn from_arg_matches_mut(
__clap_arg_matches: &mut ArgMatches,
) -> Result<Self, Error>
fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>
Source§fn update_from_arg_matches(
&mut self,
__clap_arg_matches: &ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>
ArgMatches to self.Source§fn update_from_arg_matches_mut(
&mut self,
__clap_arg_matches: &mut ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches_mut( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>
ArgMatches to self.