1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
use std::path::PathBuf;
use clap::Parser;
#[derive(Debug, Parser)]
#[clap(
author = "Dimitri Sabadie <hadronized@strongly-typed-thoughts.net>",
name = "kak-tree-sitter",
version = env!("VERSION"),
about = "A client/server interface between Kakoune and tree-sitter."
)]
pub struct Cli {
/// Whether we start from Kakoune.
///
/// This is mainly used to select a specific logger.
#[clap(short, long)]
pub kakoune: bool,
/// Initiate the current session by injecting some rc.
#[clap(long, value_name = "SESSION")]
pub init: Option<String>,
/// Start the server, if not already started.
#[clap(short, long)]
pub server: bool,
/// Try to daemonize, if not already done.
#[clap(short, long)]
pub daemonize: bool,
/// Kakoune client to connect with, if any.
#[clap(short, long)]
pub client: Option<String>,
/// JSON-serialized request.
#[clap(short, long)]
pub request: Option<String>,
/// Verbosity.
///
/// Can be accumulated to get more verbosity. Without this flag, logging is disabled. Then, for each applicaton of the
/// flag, the obtained verbosity follows this order: error, warn, info, debug, trace. Thus, if you use -v, you will
/// only get error messages. If you use -vv, you will also see warnings. The maximum verbosity is achieved with -vvvvv
/// for trace logs.
#[arg(short, long, action = clap::ArgAction::Count)]
pub verbose: u8,
/// Insert Kakoune code related to highlighting.
///
/// Highlighting is supported mainly via hooks and commands that ping-ping between Kakoune and KTS.
#[arg(long)]
pub with_highlighting: bool,
/// Insert Kakoune commands, user modes and mappings related to text-objects.
///
/// Those are default and completely optional. It is advised to start with those and if further customization is
/// needed, you shall not use this flag and craft your own user modes and mappings.
///
/// Text-objects user-modes will be available via the 'tree-sitter' user-mode.
#[arg(long)]
pub with_text_objects: bool,
/// Specify a custom user-config.
#[arg(long)]
pub config: Option<PathBuf>,
}
impl Cli {
pub fn is_standalone(&self) -> bool {
self.server && self.init.is_none()
}
}