Skip to content

Commit bc21bc4

Browse files
committed
Require config and prevent empty cache creation
- Fail all commands (except init) if .acp.config.json is missing - Show helpful message directing users to run 'acp init' - Fail index command if no files match include patterns - Display current patterns to help debug configuration issues
1 parent f82ed0f commit bc21bc4

2 files changed

Lines changed: 32 additions & 4 deletions

File tree

.gitignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ examples/**/.acp.vars.json
5252

5353
# Documentation build
5454
docs/_build/
55-
site/
56-
# ACP generated output
57-
.acp/
55+
site/
56+
# ACP generated output
57+
.acp/
58+
59+
tmp/

cli/src/main.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,18 @@ async fn main() -> anyhow::Result<()> {
301301
Config::default()
302302
};
303303

304+
// Check for config requirement (all commands except init require .acp.config.json)
305+
let requires_config = !matches!(cli.command, Commands::Init { .. });
306+
if requires_config {
307+
let config_path = PathBuf::from(".acp.config.json");
308+
if !config_path.exists() {
309+
eprintln!("{} No .acp.config.json found in project root", style("✗").red());
310+
eprintln!(" Run 'acp init' to initialize the project");
311+
eprintln!(" Use 'acp init --help' for configuration options");
312+
std::process::exit(1);
313+
}
314+
}
315+
304316
match cli.command {
305317
Commands::Init { force, include, exclude, cache_path, vars_path, workers, yes } => {
306318
use dialoguer::{theme::ColorfulTheme, Confirm, Input, MultiSelect};
@@ -442,9 +454,23 @@ async fn main() -> anyhow::Result<()> {
442454
}
443455
};
444456

445-
let indexer = Indexer::new(config)?;
457+
let indexer = Indexer::new(config.clone())?;
446458
let cache = indexer.index(&root).await?;
447459

460+
// Fail if no files were found
461+
if cache.stats.files == 0 {
462+
eprintln!("{} No files found matching include patterns", style("✗").red());
463+
eprintln!(" Check your .acp.config.json include/exclude patterns");
464+
eprintln!(" Current patterns:");
465+
for pattern in &config.include {
466+
eprintln!(" include: {}", pattern);
467+
}
468+
for pattern in &config.exclude {
469+
eprintln!(" exclude: {}", pattern);
470+
}
471+
std::process::exit(1);
472+
}
473+
448474
// Create output directory if needed
449475
if let Some(parent) = output.parent() {
450476
if !parent.as_os_str().is_empty() && !parent.exists() {

0 commit comments

Comments
 (0)