Add outline-cli: minimal CLI for search and document retrieval
Adds a command-line client in cli/ as its own Cargo workspace, depending on the outline library via a path dependency. Covers exactly the requested scope: login (stores the API key in the system keyring via the Secret Service D-Bus protocol, verified against auth.info() before storing), search (full-text), and get (fetch a document, render its markdown to a self-contained HTML page, open it in the default browser). Verified end-to-end against a real Outline instance and the local gnome-keyring: login stores and search/get retrieve the token purely from the keyring and saved config, with no environment variables set.
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
use clap::{Args, Parser, Subcommand};
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
#[command(
|
||||
name = "outline",
|
||||
version,
|
||||
about = "Search and read Outline documents from the terminal"
|
||||
)]
|
||||
pub struct Cli {
|
||||
/// Outline instance to talk to (default: <https://app.getoutline.com>)
|
||||
#[arg(long, global = true, value_name = "URL", env = "OUTLINE_URL")]
|
||||
pub base_url: Option<String>,
|
||||
|
||||
/// API key. Prefer `outline login`: arguments are visible in the process list.
|
||||
#[arg(
|
||||
long,
|
||||
global = true,
|
||||
value_name = "KEY",
|
||||
env = "OUTLINE_API_KEY",
|
||||
hide_env_values = true
|
||||
)]
|
||||
pub api_key: Option<String>,
|
||||
|
||||
#[command(subcommand)]
|
||||
pub command: Command,
|
||||
}
|
||||
|
||||
#[derive(Debug, Subcommand)]
|
||||
pub enum Command {
|
||||
/// Store an API key for the configured Outline instance in the system keyring
|
||||
Login,
|
||||
/// Full-text search documents
|
||||
Search(SearchArgs),
|
||||
/// Fetch a document, render it to HTML and open it in the browser
|
||||
Get(GetArgs),
|
||||
}
|
||||
|
||||
#[derive(Debug, Args)]
|
||||
pub struct SearchArgs {
|
||||
/// The search query
|
||||
pub query: String,
|
||||
|
||||
/// Maximum number of results to show
|
||||
#[arg(short = 'n', long, default_value_t = 10)]
|
||||
pub limit: u32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Args)]
|
||||
pub struct GetArgs {
|
||||
/// Document id, urlId, or a full Outline document URL
|
||||
pub reference: String,
|
||||
}
|
||||
Reference in New Issue
Block a user