# git-custom-cli
`gct` is a fast, keyboard-driven terminal UI for creating Git commits with a custom date, branch, and multiline message.
It is written in Rust and uses `crossterm` for a responsive Windows, macOS, and Linux terminal interface.
## Install
Install the published crate with Cargo:
```sh
cargo install git-custom-cli
```
Then run it inside an existing Git repository:
```sh
gct
```
The executable is named `gct`, while the package is named `git-custom-cli`.
## Requirements
- Rust and Cargo 1.74 or newer
- Git 2.x available on `PATH`
- A terminal that supports raw keyboard input
Modern Windows Terminal, PowerShell, Command Prompt, macOS Terminal, and common Linux terminals are supported.
## What It Does
`gct` provides a menu-driven commit workflow:
1. Shows the current branch and working-tree status.
2. Lets you edit the commit date with a keyboard-controlled date mask.
3. Lets you edit the commit time with a keyboard-controlled time mask.
4. Lets you choose the branch to push.
5. Provides an inline multiline message editor.
6. Provides an external editor option using `VISUAL`, `EDITOR`, Notepad on Windows, or `vi` on Unix-like systems.
7. Shows a final summary before any Git operation runs.
8. Stages all files and creates a normal or amended commit.
9. Saves successful values for the next run.
10. Optionally pushes to `origin` after the commit.
## Menu Controls
| Up / Down | Move through the menu |
| `w` / `s` | Move through the menu |
| Enter / Space | Select an item |
| Escape / `q` | Cancel the current menu |
| Ctrl+C | Cancel and exit |
The interface uses a centered panel that adapts to the terminal size. The active menu item is highlighted, and the status header shows the current branch and working-tree state.
## Date and Time Editing
Date format:
```text
YYYY-MM-DD
```
Time format:
```text
HH:MM:SS
```
The highlighted slot is the current keyboard cursor. Use digits to fill it, then move automatically to the next slot. Left and Right move between slots; Home and End jump to the first and last slot; Backspace and Delete clear values.
Invalid calendar dates and out-of-range times are rejected before continuing.
## Commit Modes
### Normal commit
Runs:
```text
git add .
git commit -m "message"
```
The selected date is passed through both `GIT_AUTHOR_DATE` and `GIT_COMMITTER_DATE`.
### Amend
Amend mode runs:
```text
git add .
git commit --amend -m "message"
```
If you push an amended commit, `gct` uses `--force-with-lease`.
### Dry run
Dry run validates the values and displays the commands without staging, committing, saving preferences, or pushing.
## Saved Preferences
After a successful commit, `gct` stores the last date, branch, and message in a JSON configuration file.
Typical location:
```text
Windows: %USERPROFILE%\\.config\\git-commit-tui\\config.json
macOS/Linux: ~/.config/git-commit-tui/config.json
```
Clear saved values with:
```sh
gct --clear-config
```
## External Editor
Editor selection uses this order:
1. `VISUAL`
2. `EDITOR`
3. `notepad` on Windows
4. `vi` on macOS/Linux
Example:
```powershell
$env:EDITOR = "code --wait"
gct
```
## Error Behavior
Errors are returned cleanly and the terminal is restored before the message is printed. Common errors include:
- Running outside a Git repository
- Invalid dates or times
- Empty branch or commit message
- Git identity not configured
- Git commit or push failures
- External editor startup or exit failures
## Build From Source
```sh
git clone <repository-url>
cd git-custom-cli
cargo build --release
```
The optimized executable is created at:
```text
target/release/gct
```
Run checks locally:
```sh
cargo fmt --check
cargo check
cargo test
cargo package --allow-dirty
```
## Project Layout
```text
src/main.rs CLI entry point and application workflow
src/input.rs Menu, editors, date/time input, confirmations
src/terminal.rs Centered terminal UI and redraw handling
src/git.rs Git subprocess operations
src/config.rs Saved preference storage
src/model.rs State and validation helpers
```
## License
Licensed under the MIT License. See [LICENSE](LICENSE).