git_x/
lib.rs

1// Core abstractions and utilities
2pub mod core;
3
4// Domain layer - business logic
5pub mod domain;
6
7// Adapter layer - connects CLI to domain
8pub mod adapters;
9
10// Command implementations organized by domain
11pub mod commands;
12
13// CLI interface
14pub mod cli;
15
16// Test utilities for direct command testing (improves test coverage)
17pub mod test_utils;
18
19// Examples showing architecture migration
20#[cfg(test)]
21pub mod examples;
22
23// Legacy module exports for backward compatibility
24// These will eventually be removed as we migrate to the new structure
25
26// Module exports
27pub mod bisect;
28pub mod clean_branches;
29pub mod color_graph;
30pub mod command;
31pub mod contributors;
32pub mod fixup;
33pub mod graph;
34pub mod health;
35// pub mod info;  // MIGRATED: Now in commands::repository::InfoCommand
36pub mod large_files;
37pub mod new_branch;
38pub mod prune_branches;
39pub mod rename_branch;
40pub mod since;
41pub mod stash_branch;
42pub mod summary;
43pub mod switch_recent;
44pub mod sync;
45pub mod technical_debt;
46pub mod undo;
47pub mod upstream;
48pub mod what;
49
50/// Common error type for git-x operations
51#[derive(Debug)]
52pub enum GitXError {
53    GitCommand(String),
54    Io(std::io::Error),
55    Parse(String),
56}
57
58impl std::fmt::Display for GitXError {
59    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
60        match self {
61            GitXError::GitCommand(cmd) => write!(f, "Git command failed: {cmd}"),
62            GitXError::Io(err) => write!(f, "IO error: {err}"),
63            GitXError::Parse(msg) => write!(f, "Parse error: {msg}"),
64        }
65    }
66}
67
68impl std::error::Error for GitXError {
69    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
70        match self {
71            GitXError::Io(err) => Some(err),
72            GitXError::GitCommand(_) | GitXError::Parse(_) => None,
73        }
74    }
75}
76
77impl From<std::io::Error> for GitXError {
78    fn from(err: std::io::Error) -> Self {
79        GitXError::Io(err)
80    }
81}
82
83pub type Result<T> = std::result::Result<T, GitXError>;