kagi-cli 0.1.0

A command-line interface for Kagi.com's APIs
Documentation
use clap::{Parser, Subcommand};
use kagi_api::v0::universal_summarizer::{Engine, Language, SummaryType};

use crate::render::OutputFormat;

/// This is a good place to describe setting up an API key...
///
/// I wonder if it will show up in the help message?
#[derive(Parser, Debug, Clone)]
#[command(author, version, about, long_about = None)]
pub struct Args {
    /// Print the result in a single line
    #[arg(short, long, default_value_t = false)]
    pub compact: bool,

    /// [possible values: markdown, json, debug]
    #[arg(short, long, default_value_t = OutputFormat::Markdown)]
    pub format: OutputFormat,

    /// Give a pre-recorded response, if logfile is available and contains query
    #[arg(long, default_value_t = false)]
    pub replay: bool,

    /// Word-wrap output so it fits terminal
    #[arg(short, long, default_value_t = false)]
    pub word_wrap: bool,

    #[command(subcommand)]
    pub command: KagiCommand,
}

#[derive(Subcommand, Debug, Clone)]
pub enum KagiCommand {
    /// Kagi's GPT-powered Search
    FastGpt {
        /// Search query
        query: String,

        /// Use cache
        #[arg(short, long)]
        cache: bool,
    },

    /// Kagi's Universal Summarizer
    Summarize {
        /// URL or text of any length
        subject: String,

        /// Summaries are paragraphs, takeaways are bullet points
        ///
        /// [possible values: summary, takeaway]
        #[arg(short = 't', long = "type")]
        summary_type: Option<SummaryType>,

        /// Decides "flavor" of the summarization text. Possible values:
        ///
        /// cecil (default): Friendly, descriptive, fast summary
        ///
        /// agnes: Formal, technical, analytical summary
        ///
        /// daphne: Informal, creative, friendly summary
        ///
        /// muriel: Best-in-class, enterprise-grade summary
        #[arg(short, long)]
        engine: Option<Engine>,

        /// Desired output language. Possible values:
        ///
        /// bg, cs, da, de, el, en, es, et, fi, fr, hu, id, it, ja, ko,
        ///
        /// lt, lv, nb, nl, pl, pt, ro, ru, sk, sl, sv, tr, uk, zh,
        #[arg(short = 'l', long = "language")]
        target_language: Option<Language>,

        /// Use cache
        #[arg(short, long)]
        cache: bool,
    },

    /// Generate CLI completion
    Completion { shell: clap_complete::Shell },
}