mod dupes;
mod env;
use std::path::PathBuf;
use fallow_types::output_format::OutputFormat;
use fallow_types::sourced::{Given, Origin};
use serde::Serialize;
pub use dupes::DupesInputs;
pub use env::{EnvProblem, EnvSnapshot, EnvValue, EnvVar};
use crate::{PlannedAnalysis, TypeAwareRequire};
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct TypeAwareInputs {
pub enabled: Option<Given<bool>>,
pub projects: Option<Given<Vec<PathBuf>>>,
pub require: Option<Given<TypeAwareRequire>>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, schemars::JsonSchema)]
#[serde(rename_all = "kebab-case")]
pub enum Surface {
Cli,
Api,
Node,
Lsp,
Mcp,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, schemars::JsonSchema)]
#[serde(rename_all = "kebab-case")]
pub enum CommandKind {
Combined,
Audit,
DeadCode,
Dupes,
Health,
List,
Fix,
Watch,
Viz,
Flags,
Suppressions,
TraceDependency,
TracePath,
TraceChain,
TraceError,
Security,
Inspect,
CoverageAnalyze,
CoverageUpload,
Guard,
RulePack,
BaselinesPrune,
Mutation,
SimilarCode,
PluginCheck,
DecisionSurface,
Doctor,
Editor,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum SelectionInput {
Lists {
only: Vec<PlannedAnalysis>,
skip: Vec<PlannedAnalysis>,
origin: Origin,
},
Booleans {
dead_code: bool,
duplication: bool,
health: bool,
origin: Origin,
},
Options {
dead_code: Option<bool>,
duplication: Option<bool>,
health: Option<bool>,
origin: Origin,
},
Single(PlannedAnalysis),
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub enum ConfigFallback {
#[default]
Fail,
DefaultsOnDiscoveredError,
}
#[derive(Debug, Clone)]
pub struct RunInputs {
surface: Surface,
env: EnvSnapshot,
pub command: CommandKind,
pub selection: SelectionInput,
pub config_fallback: ConfigFallback,
pub root: Option<Given<PathBuf>>,
pub config_path: Option<Given<PathBuf>>,
pub allow_remote_extends: Option<Given<bool>>,
pub no_cache: Option<Given<bool>>,
pub threads: Option<Given<usize>>,
pub max_file_size_mb: Option<Given<u32>>,
pub cache_dir: Option<Given<PathBuf>>,
pub package_baselines: Option<Given<bool>>,
pub include_entry_exports: Option<Given<bool>>,
pub production: Option<Given<bool>>,
pub production_dead_code: Option<Given<bool>>,
pub production_health: Option<Given<bool>>,
pub production_dupes: Option<Given<bool>>,
pub analysis_flags: Vec<(PlannedAnalysis, Origin)>,
pub type_aware: TypeAwareInputs,
pub audit_base: Option<Given<String>>,
pub output: OutputFormat,
pub quiet: bool,
}
impl RunInputs {
#[must_use]
pub fn new(
surface: Surface,
env: EnvSnapshot,
command: CommandKind,
selection: SelectionInput,
) -> Self {
Self {
surface,
env,
command,
selection,
config_fallback: ConfigFallback::Fail,
root: None,
config_path: None,
allow_remote_extends: None,
no_cache: None,
threads: None,
max_file_size_mb: None,
cache_dir: None,
package_baselines: None,
include_entry_exports: None,
production: None,
production_dead_code: None,
production_health: None,
production_dupes: None,
analysis_flags: Vec::new(),
type_aware: TypeAwareInputs::default(),
audit_base: None,
output: OutputFormat::Human,
quiet: true,
}
}
#[must_use]
pub const fn surface(&self) -> Surface {
self.surface
}
#[must_use]
pub const fn env(&self) -> &EnvSnapshot {
&self.env
}
}
#[derive(Debug, Clone)]
pub struct HostInputs {
pub surface: Surface,
pub env: EnvSnapshot,
}