Skip to content

Commit 4e31a24

Browse files
unhappychoiceclaude
andcommitted
refactor: move cli module to presentation layer for clean architecture
This commit moves the CLI module from src/cli to src/presentation/cli and updates all references accordingly. This establishes the presentation layer as outlined in issue #267 clean architecture separation. Changes: - Move src/cli/* to src/presentation/cli/ - Create src/presentation/mod.rs with cli module declaration - Update main.rs import from cli to presentation::cli - Update all internal cli self-references to presentation::cli - Maintain all CLI functionality including commands and views All tests pass and the refactoring preserves existing functionality while establishing the foundation for the presentation layer. This separates the CLI interface from business logic as required for clean architecture. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 5761a43 commit 4e31a24

20 files changed

+19
-18
lines changed

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pub mod infrastructure;
2-
pub mod cli;
2+
pub mod presentation;
33
pub mod config;
44
pub mod error;
55
pub mod extractor;

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use clap::Parser;
2-
use gittype::cli::{run_cli, Cli};
2+
use gittype::presentation::cli::{run_cli, Cli};
33
use gittype::logging::log_error_to_file;
44
use gittype::signal_handler::setup_signal_handlers;
55

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::cli::args::Cli;
1+
use crate::presentation::cli::args::Cli;
22
use crate::extractor::ExtractionOptions;
33
use crate::game::models::ScreenType;
44
use crate::game::screen_manager::ScreenManager;
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::Result;
44
use std::io::{self, Write};
55

66
pub fn run_repo_list() -> Result<()> {
7-
use crate::cli::views::repo_list_view;
7+
use crate::presentation::cli::views::repo_list_view;
88

99
let db = Database::new()?;
1010
let repo_dao = RepositoryDao::new(&db);
@@ -98,7 +98,7 @@ pub fn run_repo_clear(force: bool) -> Result<()> {
9898
}
9999

100100
pub fn run_repo_play() -> Result<()> {
101-
use crate::cli::views::repo_play_view;
101+
use crate::presentation::cli::views::repo_play_view;
102102

103103
let db = Database::new()?;
104104
let repo_dao = RepositoryDao::new(&db);
@@ -122,7 +122,7 @@ pub fn run_repo_play() -> Result<()> {
122122
println!("Starting gittype with repository: {}", repo_spec);
123123

124124
// Create a Cli struct to pass to run_game_session
125-
let cli = crate::cli::args::Cli {
125+
let cli = crate::presentation::cli::args::Cli {
126126
repo_path: None,
127127
repo: Some(repo_spec),
128128
langs: None,
@@ -131,7 +131,7 @@ pub fn run_repo_play() -> Result<()> {
131131
};
132132

133133
// Start the game session
134-
crate::cli::commands::run_game_session(cli)
134+
crate::presentation::cli::commands::run_game_session(cli)
135135
}
136136
None => {
137137
println!("Repository selection cancelled.");
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ pub async fn run_trending(
5555

5656
if let Some(repo) = select_repository_by_name(&repos, &name) {
5757
let repo_url = format!("https://github.com/{}", repo.repo_name);
58-
let cli = crate::cli::args::Cli {
58+
let cli = crate::presentation::cli::args::Cli {
5959
repo_path: None,
6060
repo: Some(repo_url),
6161
langs: None,
6262
config: None,
6363
command: None,
6464
};
65-
return crate::cli::commands::run_game_session(cli);
65+
return crate::presentation::cli::commands::run_game_session(cli);
6666
} else {
6767
eprintln!("⚠️ Repository '{}' not found in trending list", name);
6868
return Ok(());
@@ -77,38 +77,38 @@ pub async fn run_trending(
7777
return Ok(());
7878
}
7979

80-
use crate::cli::views::trending_repository_selection_view;
80+
use crate::presentation::cli::views::trending_repository_selection_view;
8181

8282
match trending_repository_selection_view::render_trending_ui(repos.clone())? {
8383
Some(selection) => {
8484
if let Some(repo) = repos.get(selection) {
8585
let repo_url = format!("https://github.com/{}", repo.repo_name);
86-
let cli = crate::cli::args::Cli {
86+
let cli = crate::presentation::cli::args::Cli {
8787
repo_path: None,
8888
repo: Some(repo_url),
8989
langs: None,
9090
config: None,
9191
command: None,
9292
};
93-
return crate::cli::commands::run_game_session(cli);
93+
return crate::presentation::cli::commands::run_game_session(cli);
9494
}
9595
}
9696
None => return Ok(()),
9797
}
9898
} else {
9999
// No language provided - show unified selection UI
100-
use crate::cli::views::trending_unified_view;
100+
use crate::presentation::cli::views::trending_unified_view;
101101

102102
match trending_unified_view::render_trending_selection_ui().await? {
103103
Some(repo_url) => {
104-
let cli = crate::cli::args::Cli {
104+
let cli = crate::presentation::cli::args::Cli {
105105
repo_path: None,
106106
repo: Some(repo_url),
107107
langs: None,
108108
config: None,
109109
command: None,
110110
};
111-
return crate::cli::commands::run_game_session(cli);
111+
return crate::presentation::cli::commands::run_game_session(cli);
112112
}
113113
None => return Ok(()),
114114
}

0 commit comments

Comments
 (0)