Skip to content
This repository has been archived by the owner on Sep 22, 2024. It is now read-only.

ktsctl improvements #302

Merged
merged 5 commits into from
Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions docs/man/ktsctl.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ Usage: `ktsctl <COMMAND>`. Commands can be:

`ktsctl manage --help` will provide more than enough help for you to get started, but here’s some more:

- A typical one-liner to install a language is `ktsctl manage -fci <LANG>`.
- A typical one-liner to install a language is `ktsctl manage -fcil <LANG>`.
- `-f, --fetch` will make `ktsctl` fetch and download grammars and queries. You can decide to first fetch resources for
a given language, and then call the other commands later without fetching anymore; or you can combine everything at
once.
- `-c, --compile` compiles and link grammars.
- `-i, --install` installs grammars and queries into `$XDG_DATA_HOME/kak-tree-sitter`. The install path can change
depending on the operating system (for instance, it might be `$HOME/Library/Application\ Support` for macOS).
- `<LANG>` is the name of the language to install.
- `-l, --language <LANG>` is the name of the language to install.

> The list of language names you can installed can be found with the [info command](#getting-information).

Expand All @@ -40,6 +40,14 @@ For instance, to fetch, compile and install the grammar and queries for the Rust
ktsctl manage -fci rust
```

#### Installing all languages at once

A useful one-liner that you can use to install everything at once is to use the `-a, --all` flag:

```bash
ktscstl manage -fcia
```

### Getting information

The `info` command allows to get information about tree-sitter resources. As with `manage`, you can use `--help` to know
Expand Down
24 changes: 24 additions & 0 deletions kak-tree-sitter-config/src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use std::{io, path::PathBuf};

use thiserror::Error;

#[derive(Debug, Error)]
pub enum ConfigError {
#[error("no configuration directory known for your system; please adjust XDG_CONFIG_HOME")]
NoConfigDir,

#[error("cannot read configuration at {path}: {err}")]
CannotReadConfig { path: PathBuf, err: io::Error },

#[error("cannot parse configuration: {err}")]
CannotParseConfig { err: String },

#[error("missing configuration option: {opt}")]
MissingOption { opt: String },
}

impl ConfigError {
pub fn missing_opt(opt: impl Into<String>) -> Self {
Self::MissingOption { opt: opt.into() }
}
}
26 changes: 3 additions & 23 deletions kak-tree-sitter-config/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,37 +1,17 @@
//! Configuration for both the daemon and client.

pub mod error;
pub mod source;

use std::{
collections::{HashMap, HashSet},
fs, io,
fs,
path::{Path, PathBuf},
};

use error::ConfigError;
use serde::{Deserialize, Serialize};
use source::{Source, UserSource};
use thiserror::Error;

#[derive(Debug, Error)]
pub enum ConfigError {
#[error("no configuration directory known for your system; please adjust XDG_CONFIG_HOME")]
NoConfigDir,

#[error("cannot read configuration at {path}: {err}")]
CannotReadConfig { path: PathBuf, err: io::Error },

#[error("cannot parse configuration: {err}")]
CannotParseConfig { err: String },

#[error("missing configuration option: {opt}")]
MissingOption { opt: String },
}

impl ConfigError {
pub fn missing_opt(opt: impl Into<String>) -> Self {
Self::MissingOption { opt: opt.into() }
}
}

/// Configuration object used in the server and controller.
///
Expand Down
2 changes: 1 addition & 1 deletion kak-tree-sitter/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{io, path::PathBuf};

use kak_tree_sitter_config::ConfigError;
use kak_tree_sitter_config::error::ConfigError;
use log::SetLoggerError;
use thiserror::Error;
use tree_sitter::{LanguageError, QueryError};
Expand Down
1 change: 1 addition & 0 deletions ktsctl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ kak-tree-sitter-config = { version = "0.4.0-dev", path = "../kak-tree-sitter-con
log = "0.4.21"
simple_logger = "4.3.3"
thiserror = "1.0.57"
unicode-segmentation = "1.11.0"
2 changes: 1 addition & 1 deletion ktsctl/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub enum Cmd {
},

/// Get information on installed resources.
Info {
Query {
/// Get information about a specific language.
#[clap(short, long)]
lang: Option<String>,
Expand Down
4 changes: 4 additions & 0 deletions ktsctl/src/commands.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//! Main commands supported by ktsctl.

pub mod manage;
pub mod query;
Loading
Loading