Skip to content

refactor(#131): extract CLI structs and logging into dedicated modules - #298

Merged
ajianaz merged 1 commit into
developfrom
refactor/131-cli-modular-structure
Jun 12, 2026
Merged

ajianaz merged 1 commit into
developfrom
refactor/131-cli-modular-structure

Conversation

@ajianaz

@ajianaz ajianaz commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Extract CLI argument definitions into cli.rs and logging setup into logging.rs. main.rs reduced from 449 to ~100 lines.

Also adds .cora.yaml config with pre-commit hook (Cora v0.5.0).

Closes #131

Extract CLI argument definitions (clap structs/enums) into cli.rs and
logging setup into logging.rs. main.rs reduced from 449 to ~100 lines.

- cli.rs: Cli struct, Commands enum, TagCommands, NamespaceCommands,
  AgingCommands, SupportedShell
- logging.rs: init() with console + daily rotating file appender
- main.rs: entry point only (parse, logging, config, dispatch)
- All crate::X imports updated to crate::cli::X in command modules
- logging.rs: create log dir if missing, fallback to temp instead of cwd
- Added .cora.yaml config (pre-commit hook installed)

Also adds .cora/ to .gitignore (local Cora cache directory).
/// Delete all memories with this tag
#[arg(long)]
tag: Option<String>,
/// Delete all cold (not accessed in 30+ days) memories

/// Initialize logging. Returns a guard that must stay alive for the
/// file writer to continue flushing.
pub fn init(verbose: bool) -> Box<dyn std::any::Any + Send> {
let log_dir = dirs::home_dir()
.map(|h| h.join(".uteke"))
.filter(|d| d.is_dir() || std::fs::create_dir_all(d).is_ok())
.unwrap_or_else(|| {
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

❌ Blocked — critical issues found.

🔴 Error (3)

  • crates/uteke-cli/src/logging.rs:11 — The new logging::init hardcodes the log directory to dirs::home_dir().join(".uteke"), while the CLI supports overriding the store location via --store and config (main.rs later resolves store_path from CLI/config/default). This causes logs to be written to a different location than the active store whenever a custom store path is used, which is a functional regression from the rest of the CLI's path resolution model.
  • crates/uteke-cli/src/logging.rs:15 — If home_dir() is unavailable or create_dir_all fails, log_dir falls back to std::env::temp_dir().join("uteke"), but that fallback path is never created. tracing_appender::rolling::daily(&log_dir, "uteke.log") is then initialized against a directory that may not exist, so file logging can silently fail in exactly the fallback case this code is trying to handle.
  • crates/uteke-cli/src/cli.rs:135 — Static security scanner detected: SQL injection via string concatenation in crates/uteke-cli/src/cli.rs:135

Review powered by cora-cli · BYOK · MIT

@ajianaz
ajianaz merged commit 9f28835 into develop Jun 12, 2026
8 of 9 checks passed
@ajianaz
ajianaz deleted the refactor/131-cli-modular-structure branch June 12, 2026 03:24
ajianaz added a commit that referenced this pull request Aug 13, 2026
#298)

Extract CLI argument definitions (clap structs/enums) into cli.rs and
logging setup into logging.rs. main.rs reduced from 449 to ~100 lines.

- cli.rs: Cli struct, Commands enum, TagCommands, NamespaceCommands,
  AgingCommands, SupportedShell
- logging.rs: init() with console + daily rotating file appender
- main.rs: entry point only (parse, logging, config, dispatch)
- All crate::X imports updated to crate::cli::X in command modules
- logging.rs: create log dir if missing, fallback to temp instead of cwd
- Added .cora.yaml config (pre-commit hook installed)

Also adds .cora/ to .gitignore (local Cora cache directory).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🔧 [P1] Split main.rs monolith into modular structure

2 participants