pub struct CliContext {
pub config_path: PathBuf,
pub log_level: Level,
pub working_dir: PathBuf,
/* private fields */
}Expand description
CLI execution context
This provides normalized runtime configuration for the CLI, combining:
- CLI flags
- Environment variables
- Config file settings
- Computed defaults
Use CliContextBuilder to construct with proper precedence handling.
§Example
use mecha10_cli::{CliContext, CliContextBuilder};
let ctx = CliContextBuilder::new()
.verbose(true)
.build()?;
assert!(ctx.is_verbose());Fields§
§config_path: PathBufPath to the project config file (mecha10.json)
log_level: LevelLogging level
working_dir: PathBufProject working directory
Implementations§
Source§impl CliContext
impl CliContext
Sourcepub async fn load_project_config(&self) -> Result<ProjectConfig>
pub async fn load_project_config(&self) -> Result<ProjectConfig>
Load the project configuration
This loads the configuration from disk each time it’s called. For better performance in commands that access config multiple times, call this once and store the result.
Sourcepub fn is_project_initialized(&self) -> bool
pub fn is_project_initialized(&self) -> bool
Check if a project is initialized (mecha10.json exists)
Sourcepub fn project_path(&self, path: &str) -> PathBuf
pub fn project_path(&self, path: &str) -> PathBuf
Get a path relative to the project root
Sourcepub fn is_verbose(&self) -> bool
pub fn is_verbose(&self) -> bool
Check if verbose mode is enabled
Sourcepub fn is_dev_mode(&self) -> bool
pub fn is_dev_mode(&self) -> bool
Check if development mode is enabled
Sourcepub fn postgres_url(&self) -> Option<&str>
pub fn postgres_url(&self) -> Option<&str>
Get the PostgreSQL connection URL if configured
Sourcepub fn redis(&mut self) -> Result<&RedisService>
pub fn redis(&mut self) -> Result<&RedisService>
Get Redis service (creates on first access)
Sourcepub fn project(&mut self) -> Result<&ProjectService>
pub fn project(&mut self) -> Result<&ProjectService>
Get Project service (creates on first access)
Sourcepub fn template(&mut self) -> &TemplateService
pub fn template(&mut self) -> &TemplateService
Get Template service (creates on first access)
Sourcepub fn simulation(&mut self) -> &SimulationService
pub fn simulation(&mut self) -> &SimulationService
Get Simulation service (creates on first access)
Sourcepub fn process(&mut self) -> &mut ProcessService
pub fn process(&mut self) -> &mut ProcessService
Get Process service (creates on first access)
Sourcepub fn docker(&mut self) -> &DockerService
pub fn docker(&mut self) -> &DockerService
Get Docker service (creates on first access)
Sourcepub fn package(&mut self) -> Result<&PackageService>
pub fn package(&mut self) -> Result<&PackageService>
Get Package service (creates on first access)
Note: This requires a valid project to be detected with name and version.
Sourcepub fn deployment(&mut self) -> &DeploymentService
pub fn deployment(&mut self) -> &DeploymentService
Get Deployment service (creates on first access)
Sourcepub fn component_catalog(&mut self) -> &ComponentCatalogService
pub fn component_catalog(&mut self) -> &ComponentCatalogService
Get Component Catalog service (creates on first access)
Sourcepub fn discovery(&mut self) -> &mut DiscoveryService
pub fn discovery(&mut self) -> &mut DiscoveryService
Get Discovery service (creates on first access)
Sourcepub fn init_service(&mut self) -> &InitService
pub fn init_service(&mut self) -> &InitService
Get Init service (creates on first access)
Sourcepub fn project_template_service(&mut self) -> &ProjectTemplateService
pub fn project_template_service(&mut self) -> &ProjectTemplateService
Get Project Template service (creates on first access)
Sourcepub fn dev(&mut self) -> &DevService
pub fn dev(&mut self) -> &DevService
Get Dev service (creates on first access)
Sourcepub fn topology(&mut self) -> &TopologyService
pub fn topology(&mut self) -> &TopologyService
Get Topology service (creates on first access)
The topology service performs static analysis of project structure, extracting node definitions and pub/sub topic relationships from source code.
Sourcepub fn template_download(&mut self) -> &TemplateDownloadService
pub fn template_download(&mut self) -> &TemplateDownloadService
Get Template Download service (creates on first access)
Downloads project templates from GitHub releases on-demand. Templates are versioned and cached locally for offline use.
Sourcepub fn validate_docker(&mut self) -> Result<()>
pub fn validate_docker(&mut self) -> Result<()>
Validate that Docker is installed and running
Sourcepub async fn validate_redis(&mut self) -> Result<()>
pub async fn validate_redis(&mut self) -> Result<()>
Validate that Redis is accessible
Sourcepub fn validate_project_structure(&self) -> Result<()>
pub fn validate_project_structure(&self) -> Result<()>
Validate project structure
Checks that the project has the expected directory structure and required files.
Sourcepub fn validate_godot(&mut self) -> Result<()>
pub fn validate_godot(&mut self) -> Result<()>
Validate that Godot is installed (for simulation)
Sourcepub fn is_interactive(&self) -> bool
pub fn is_interactive(&self) -> bool
Check if running in interactive terminal
Sourcepub fn recordings_dir(&self) -> PathBuf
pub fn recordings_dir(&self) -> PathBuf
Get recordings directory path
Sourcepub fn telemetry_dir(&self) -> PathBuf
pub fn telemetry_dir(&self) -> PathBuf
Get telemetry directory path
Sourcepub fn simulation_dir(&self) -> PathBuf
pub fn simulation_dir(&self) -> PathBuf
Get simulation directory path
Sourcepub fn target_debug_dir(&self) -> PathBuf
pub fn target_debug_dir(&self) -> PathBuf
Get target/debug directory path
Sourcepub fn target_release_dir(&self) -> PathBuf
pub fn target_release_dir(&self) -> PathBuf
Get target/release directory path
Sourcepub fn packages_dir(&self) -> PathBuf
pub fn packages_dir(&self) -> PathBuf
Get packages output directory path
Sourcepub fn ensure_dir(&self, path: &PathBuf) -> Result<()>
pub fn ensure_dir(&self, path: &PathBuf) -> Result<()>
Ensure a directory exists, creating it if necessary
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CliContext
impl !RefUnwindSafe for CliContext
impl Send for CliContext
impl Sync for CliContext
impl Unpin for CliContext
impl !UnwindSafe for CliContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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