Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ tokio = { version = "1.47.1", features = ["full"] }
once_cell = "1.21.3"
uuid = {version = "1.18.0", features = ["v4"]}
async-trait = "0.1.83"
# TUI dependencies
ratatui = "0.29.0"
crossterm = "0.28.1"
tui-textarea = "0.6.1"

[dev-dependencies]
assert_cmd = "2.0.17"
Expand Down
1 change: 1 addition & 0 deletions src/cli/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ pub mod group_commit;
pub mod lint;
pub mod lint_message;
pub mod tag;
pub mod tui;
42 changes: 42 additions & 0 deletions src/cli/commands/tui.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
use crate::cli::Command;
use crate::error::CliError;
use crate::tui::{self, App};
use log::info;
use structopt::StructOpt;

#[derive(Debug, StructOpt)]
pub struct TuiCommand {
#[structopt(long = "ai", help = "Enable AI assistance for commit messages")]
ai: bool,

#[structopt(long = "ai-provider", default_value = "openrouter", possible_values = &["openrouter", "ollama"])]
ai_provider: String,

#[structopt(long = "ai-model", help = "AI model to use")]
ai_model: Option<String>,
}

impl Command for TuiCommand {
fn execute(&self, _non_interactive: bool) -> Result<(), CliError> {
info!("🚀 Starting Committy TUI");

// Initialize terminal
let mut terminal = tui::init()?;

// Create app
let mut app = App::new()?;

// Set AI options if enabled
if self.ai {
app.state.ai_enabled = true;
}

// Run the TUI
let result = app.run(&mut terminal);

// Restore terminal
tui::restore()?;

result
}
}
5 changes: 4 additions & 1 deletion src/cli/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub mod commands;

use self::commands::{amend, branch, commit, group_commit, lint, lint_message, tag};
use self::commands::{amend, branch, commit, group_commit, lint, lint_message, tag, tui};
use crate::error::CliError;
use structopt::StructOpt;

Expand All @@ -24,6 +24,8 @@ pub enum CliCommand {
Branch(branch::BranchCommand),
#[structopt(about = "Group changes and optionally commit/apply them (with optional AI)")]
GroupCommit(group_commit::GroupCommitCommand),
#[structopt(about = "Interactive TUI for staging and committing changes")]
Tui(tui::TuiCommand),
}

impl CliCommand {
Expand All @@ -36,6 +38,7 @@ impl CliCommand {
CliCommand::LintMessage(cmd) => cmd.execute(non_interactive),
CliCommand::Branch(cmd) => cmd.execute(non_interactive),
CliCommand::GroupCommit(cmd) => cmd.execute(non_interactive),
CliCommand::Tui(cmd) => cmd.execute(non_interactive),
}
}
}
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ pub mod linter;
pub mod logger;
pub mod release;
pub mod telemetry;
pub mod tui;
pub mod update;
pub mod version;
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ mod linter;
mod logger;
mod release;
mod telemetry;
mod tui;
mod update;
mod version;

Expand Down
Loading
Loading