kak-tree-sitter 3.2.1

Server between Kakoune and tree-sitter
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()
  }
}