CliContext

Struct CliContext 

Source
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: PathBuf

Path to the project config file (mecha10.json)

§log_level: Level

Logging level

§working_dir: PathBuf

Project working directory

Implementations§

Source§

impl CliContext

Source

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.

Source

pub fn is_project_initialized(&self) -> bool

Check if a project is initialized (mecha10.json exists)

Source

pub fn project_path(&self, path: &str) -> PathBuf

Get a path relative to the project root

Source

pub fn is_verbose(&self) -> bool

Check if verbose mode is enabled

Source

pub fn is_dev_mode(&self) -> bool

Check if development mode is enabled

Source

pub fn redis_url(&self) -> &str

Get the Redis connection URL

Source

pub fn postgres_url(&self) -> Option<&str>

Get the PostgreSQL connection URL if configured

Source

pub fn redis(&mut self) -> Result<&RedisService>

Get Redis service (creates on first access)

Source

pub fn project(&mut self) -> Result<&ProjectService>

Get Project service (creates on first access)

Source

pub fn template(&mut self) -> &TemplateService

Get Template service (creates on first access)

Source

pub fn simulation(&mut self) -> &SimulationService

Get Simulation service (creates on first access)

Source

pub fn process(&mut self) -> &mut ProcessService

Get Process service (creates on first access)

Source

pub fn docker(&mut self) -> &DockerService

Get Docker service (creates on first access)

Source

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.

Source

pub fn deployment(&mut self) -> &DeploymentService

Get Deployment service (creates on first access)

Source

pub fn component_catalog(&mut self) -> &ComponentCatalogService

Get Component Catalog service (creates on first access)

Source

pub fn discovery(&mut self) -> &mut DiscoveryService

Get Discovery service (creates on first access)

Source

pub fn init_service(&mut self) -> &InitService

Get Init service (creates on first access)

Source

pub fn project_template_service(&mut self) -> &ProjectTemplateService

Get Project Template service (creates on first access)

Source

pub fn dev(&mut self) -> &DevService

Get Dev service (creates on first access)

Source

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.

Source

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.

Source

pub fn validate_docker(&mut self) -> Result<()>

Validate that Docker is installed and running

Source

pub async fn validate_redis(&mut self) -> Result<()>

Validate that Redis is accessible

Source

pub fn validate_project_structure(&self) -> Result<()>

Validate project structure

Checks that the project has the expected directory structure and required files.

Source

pub fn validate_godot(&mut self) -> Result<()>

Validate that Godot is installed (for simulation)

Source

pub fn is_ci(&self) -> bool

Check if running in CI environment

Source

pub fn is_interactive(&self) -> bool

Check if running in interactive terminal

Source

pub fn logs_dir(&self) -> PathBuf

Get logs directory path

Source

pub fn data_dir(&self) -> PathBuf

Get data directory path

Source

pub fn recordings_dir(&self) -> PathBuf

Get recordings directory path

Source

pub fn maps_dir(&self) -> PathBuf

Get maps directory path

Source

pub fn telemetry_dir(&self) -> PathBuf

Get telemetry directory path

Source

pub fn simulation_dir(&self) -> PathBuf

Get simulation directory path

Source

pub fn target_debug_dir(&self) -> PathBuf

Get target/debug directory path

Source

pub fn target_release_dir(&self) -> PathBuf

Get target/release directory path

Source

pub fn packages_dir(&self) -> PathBuf

Get packages output directory path

Source

pub fn ensure_dir(&self, path: &PathBuf) -> Result<()>

Ensure a directory exists, creating it if necessary

Trait Implementations§

Source§

impl Default for CliContext

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> 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, 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