kagi_cli/
args.rs

1use clap::{Parser, Subcommand};
2use kagi_api::v0::universal_summarizer::{Engine, Language, SummaryType};
3
4use crate::render::OutputFormat;
5
6/// This is a good place to describe setting up an API key...
7///
8/// I wonder if it will show up in the help message?
9#[derive(Parser, Debug, Clone)]
10#[command(author, version, about, long_about = None)]
11pub struct Args {
12    /// Print the result in a single line
13    #[arg(short, long, default_value_t = false)]
14    pub compact: bool,
15
16    /// [possible values: markdown, json, debug]
17    #[arg(short, long, default_value_t = OutputFormat::Markdown)]
18    pub format: OutputFormat,
19
20    /// Give a pre-recorded response, if logfile is available and contains query
21    #[arg(long, default_value_t = false)]
22    pub replay: bool,
23
24    /// Word-wrap output so it fits terminal
25    #[arg(short, long, default_value_t = false)]
26    pub word_wrap: bool,
27
28    #[command(subcommand)]
29    pub command: KagiCommand,
30}
31
32#[derive(Subcommand, Debug, Clone)]
33pub enum KagiCommand {
34    /// Kagi's GPT-powered Search
35    FastGpt {
36        /// Search query
37        query: String,
38
39        /// Use cache
40        #[arg(short, long)]
41        cache: bool,
42    },
43
44    /// Kagi's Universal Summarizer
45    Summarize {
46        /// URL or text of any length
47        subject: String,
48
49        /// Summaries are paragraphs, takeaways are bullet points
50        ///
51        /// [possible values: summary, takeaway]
52        #[arg(short = 't', long = "type")]
53        summary_type: Option<SummaryType>,
54
55        /// Decides "flavor" of the summarization text. Possible values:
56        ///
57        /// cecil (default): Friendly, descriptive, fast summary
58        ///
59        /// agnes: Formal, technical, analytical summary
60        ///
61        /// daphne: Informal, creative, friendly summary
62        ///
63        /// muriel: Best-in-class, enterprise-grade summary
64        #[arg(short, long)]
65        engine: Option<Engine>,
66
67        /// Desired output language. Possible values:
68        ///
69        /// bg, cs, da, de, el, en, es, et, fi, fr, hu, id, it, ja, ko,
70        ///
71        /// lt, lv, nb, nl, pl, pt, ro, ru, sk, sl, sv, tr, uk, zh,
72        #[arg(short = 'l', long = "language")]
73        target_language: Option<Language>,
74
75        /// Use cache
76        #[arg(short, long)]
77        cache: bool,
78    },
79
80    /// Generate CLI completion
81    Completion { shell: clap_complete::Shell },
82}