use anyhow::Result;
mod args;
mod auth;
mod context;
mod headless;
mod issue;
mod paths;
pub use issue::issue_key;
pub const USAGE: &str = "\
linear-tui — a terminal UI for Linear
Usage:
linear-tui Open the TUI (sets up credentials on first run)
linear-tui open <ID> Open the TUI on an issue (ENG-123 or its URL)
linear-tui auth login Sign in to a workspace through the browser
linear-tui auth list List the signed-in workspaces
linear-tui auth switch <workspace>
Use another signed-in workspace (by URL key or name)
linear-tui auth status Show which credentials are in use
linear-tui auth token <key> Sign in with a personal API key
linear-tui auth logout [<workspace>] [--all]
Forget a workspace's token (--all: every token and the API key)
linear-tui auth set-oauth <client-id> [client-secret]
Authorize against your own Linear application
For agents and scripts (Markdown by default, --json for JSON):
linear-tui context [--json] [--workspace <path>]
What linear-tui is showing in this repository
linear-tui issue show <ID> [--json]
An issue with its description and comments
linear-tui issue create --team <key> --title <text> [--description <text>]
[--priority <urgent|high|medium|low|none>] [--json]
linear-tui issue comment <ID> <body> [--json]
linear-tui issue status <ID> <state> [--json]
linear-tui paths [--json] Where the config and the state (view snapshots) live
<ID> is an identifier (ENG-123) or an issue URL. A <body> or <text> of `-`
is read from stdin.
";
pub async fn handle_subcommand(args: &[String]) -> Result<()> {
match args[0].as_str() {
"auth" => auth::run(&args[1..]).await,
"context" => context::run(&args[1..]),
"issue" => issue::run(&args[1..]).await,
"paths" => paths::run(&args[1..]),
"help" | "--help" | "-h" => {
print!("{USAGE}");
Ok(())
}
"--version" | "-V" => {
println!("linear-tui {}", env!("CARGO_PKG_VERSION"));
Ok(())
}
other => {
eprint!("{USAGE}");
anyhow::bail!("unknown command: {other}")
}
}
}