-
Notifications
You must be signed in to change notification settings - Fork 0
improve tui #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
improve tui #1
Changes from 9 commits
20de228
1f07036
28cad81
1838242
4b71de3
eb37856
2caa53e
3734d15
4822177
e57cfb6
9aedf45
396c87c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # Repository Guidelines | ||
|
|
||
| ## Project Structure & Module Organization | ||
| - `src/` contains the Rust CLI/TUI implementation; entry points live in `src/main.rs` and shared logic in `src/lib.rs`. | ||
| - `src/tests.rs` and `src/tests/` hold unit tests (currently `src/tests/config_test.rs`). | ||
| - `main.ts` is the Deno entry point for the published package. | ||
| - `deno.json` and `.huk.json` define tasks and hook configuration; `schema.json` documents the config schema. | ||
| - Build outputs land in `bin/` (custom artifacts) and `target/` (Cargo defaults). | ||
|
|
||
| ## Build, Test, and Development Commands | ||
| - `deno task build` builds the release binary into `bin/` (uses Cargo under the hood). | ||
| - `deno task build:debug` builds a debug binary into `bin/`. | ||
| - `deno task test` runs `cargo test --all`; use `deno task test:verbose` for full logs. | ||
| - `deno task fmt` / `deno task fmt:check` format or verify formatting. | ||
| - `deno task lint` runs `cargo clippy --all --all-targets -- -D warnings`. | ||
| - `cargo run --bin huk -- <subcommand>` runs the CLI locally (e.g., `cargo run --bin huk -- dashboard`). | ||
|
|
||
| ## Coding Style & Naming Conventions | ||
| - Rust edition is 2024; formatting is enforced by `.rustfmt.toml` (80 column max, 2-space tabs, item-level imports). | ||
| - Use `cargo fmt` before commits and keep Clippy clean (`deno task lint`). | ||
| - Follow Rust conventions: `snake_case` for modules/functions/tests (e.g., `parse_task_spec_string`), `PascalCase` for types, and `SCREAMING_SNAKE_CASE` for constants. | ||
|
|
||
| ## Testing Guidelines | ||
| - Use `cargo test --all` or `deno task test`; tests live in `src/tests.rs` and `src/tests/*.rs`. | ||
| - Add targeted tests for config parsing, hook resolution, and task execution paths. | ||
|
|
||
| ## Commit & Pull Request Guidelines | ||
| - Commit messages follow Conventional Commits (`feat(tui): add tasks view`, `docs: update README`), with optional `[WIP]` suffix when needed. | ||
| - PRs should include a concise summary, tests run, and note any config schema or hook changes. | ||
| - Include screenshots or short clips for TUI-facing changes. | ||
|
|
||
| ## Configuration & Hook Definitions | ||
| - Define hooks in `deno.json` or `.huk.json` under the `hooks` field; tasks live under `tasks`. | ||
| - When changing config formats or validation, update `schema.json` and add/adjust tests. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,13 @@ | ||
| [toolchain] | ||
| channel = "nightly" | ||
| components = ["rustfmt", "clippy"] | ||
| components = ["rustfmt", "clippy", "cargo"] | ||
| targets = [ | ||
| "aarch64-unknown-linux-gnu", | ||
| "aarch64-unknown-linux-musl", | ||
| "aarch64-apple-darwin", | ||
| "aarch64-pc-windows-msvc", | ||
| "x86_64-unknown-linux-gnu", | ||
| "x86_64-unknown-linux-musl", | ||
| "x86_64-apple-darwin", | ||
| "x86_64-pc-windows-msvc", | ||
| ] |
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,11 +4,14 @@ | |||||||||||||||
| //! the `huk` executable exposes. It uses the [`clap`](https://crates.io/crates/clap) | ||||||||||||||||
| //! crate for ergonomic argument parsing. | ||||||||||||||||
|
|
||||||||||||||||
| use std::path::PathBuf; | ||||||||||||||||
|
|
||||||||||||||||
| use clap::Args; | ||||||||||||||||
| use clap::Parser; | ||||||||||||||||
| use clap::Subcommand; | ||||||||||||||||
| use derive_more::with_trait::IsVariant; | ||||||||||||||||
| use derive_more::with_trait::TryInto; | ||||||||||||||||
| use lazy_static::lazy_static; | ||||||||||||||||
| use paste::paste; | ||||||||||||||||
| use thiserror::Error; | ||||||||||||||||
|
|
||||||||||||||||
|
|
@@ -46,6 +49,10 @@ pub struct Cli { | |||||||||||||||
| pub command: Commands, | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| lazy_static! { | ||||||||||||||||
| static ref LAZY_CWD: PathBuf = std::env::current_dir().unwrap_or_default(); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| macro_rules! cli { | ||||||||||||||||
| ( | ||||||||||||||||
| $( | ||||||||||||||||
|
|
@@ -113,6 +120,21 @@ macro_rules! cli { | |||||||||||||||
| }; | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| const TASK_SPEC_LONG_HELP: &str = "\ | ||||||||||||||||
| Task specification to associate with the hook.\n\n\ | ||||||||||||||||
| Accepted task specification forms:\n \ | ||||||||||||||||
| 1. a raw shell command string (e.g. `\"git add -A\"`)\n \ | ||||||||||||||||
| 2. a task name from the configuration file, which must either be:\n \ | ||||||||||||||||
| - defined in the `tasks` section of a deno.json file, or ...\n \ | ||||||||||||||||
| - defined in the `scripts` section of a package.json file\n \ | ||||||||||||||||
| 3. an object with `command`, `dependencies`, and/or `description` fields, where:\n \ | ||||||||||||||||
| - `command` is a shell command string to execute,\n \ | ||||||||||||||||
| - `dependencies` is an array of tasks to run before the command,\n \ | ||||||||||||||||
| Note: this field is required if `command` is not provided.\n \ | ||||||||||||||||
| - `description` is a human-readable summary of the task (optional)\n \ | ||||||||||||||||
| 4. a sequence where value satisfies either type 1, 2, or 3 a `bove.\n \ | ||||||||||||||||
| Multiple specifications can be provided to build a sequence."; | ||||||||||||||||
|
|
||||||||||||||||
| cli! { | ||||||||||||||||
| /// Launch an interactive dashboard for managing hooks and tasks. | ||||||||||||||||
| #[command( | ||||||||||||||||
|
|
@@ -140,7 +162,12 @@ cli! { | |||||||||||||||
| ←|→ (left / right)\n \ | ||||||||||||||||
| Reposition the cursor in text fields.\n")] | ||||||||||||||||
| #[cfg(feature = "tui")] | ||||||||||||||||
| Dashboard(Default), | ||||||||||||||||
| Dashboard(Default) { | ||||||||||||||||
| /// Set the working directory to run the huk dashboard in. | ||||||||||||||||
| /// | ||||||||||||||||
| /// Defaults to the current working directory. | ||||||||||||||||
| cwd(long, short = 'C', default_value = LAZY_CWD.to_str()): Option<PathBuf>, | ||||||||||||||||
|
||||||||||||||||
| cwd(long, short = 'C', default_value = LAZY_CWD.to_str()): Option<PathBuf>, | |
| cwd(long, short = 'C'): Option<PathBuf>, |
Copilot
AI
Feb 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This adds a --cwd/-C option to the Dashboard command, but the dashboard handler currently always uses std::env::current_dir() (it takes _opts and ignores it). Either wire this flag through to the handler (use it for HookConfig::discover and for state.run(...)) or drop the option for now to avoid a misleading CLI.
| Dashboard(Default) { | |
| /// Set the working directory to run the huk dashboard in. | |
| /// | |
| /// Defaults to the current working directory. | |
| cwd(long, short = 'C', default_value = LAZY_CWD.to_str()): Option<PathBuf>, | |
| }, | |
| Dashboard(Default) {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The help text has a typo: "a `bove" should be "above" (and remove the stray backtick) so the long help renders correctly.