Skip to main content

lux_cli/util/
mod.rs

1use clap::Subcommand;
2use lux_lib::config::Config;
3
4use crate::util::{completion::Completion, man::Man};
5use miette::Result;
6
7mod completion;
8mod man;
9mod schema;
10
11#[derive(Subcommand)]
12pub enum Util {
13    /// Generate autocompletion scripts for the shell.{n}
14    /// Example: `lx completion zsh > ~/.zsh/completions/_lx`
15    Completion(Completion),
16    /// Generate manpages.
17    Man(Man),
18    /// Generate the JSON Schema for `lux.toml` or `config.toml`.
19    Schema(schema::Schema),
20}
21
22pub async fn util(util: Util, _config: Config) -> Result<()> {
23    match util {
24        Util::Completion(completion) => completion::completion(completion).await,
25        Util::Man(man) => man::man(man).await,
26        Util::Schema(schema) => schema::schema(schema),
27    }
28}