Skip to content

Commit

Permalink
Generate shell completions
Browse files Browse the repository at this point in the history
  • Loading branch information
giodamelio committed Mar 18, 2024
1 parent 3061b2e commit 0698d28
Show file tree
Hide file tree
Showing 30 changed files with 4,819 additions and 5 deletions.
10 changes: 10 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ anyhow = "1.0.81"
[build-dependencies]
clap = {version = "4.5.3", features = ["default", "cargo"]}
clap_mangen = "0.2.20"
clap_complete = "4.5.1"

[features]
18 changes: 13 additions & 5 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ use std::fs::write;
use std::io::{ErrorKind, Result};
use std::path::PathBuf;

use clap::ValueEnum;
use clap_complete::{generate_to, Shell};

// This is a bit of a hack to not have to rewrite the cli in the build
#[path = "src/cli.rs"]
mod cli;
Expand All @@ -13,17 +16,22 @@ fn main() -> Result<()> {

let out_dir = PathBuf::from(var_os("OUT_DIR").ok_or(ErrorKind::NotFound)?);
println!(
"cargo:warning=manpages built at {:?}",
out_dir.join("little_boxes.1")
"cargo:warning=manpages/completions built at {:?}",
out_dir.clone()
);

let cmd = cli::cli();
let mut cmd = cli::cli();

let man = clap_mangen::Man::new(cmd);
// Generate manpages
let man = clap_mangen::Man::new(cmd.clone());
let mut buffer: Vec<u8> = Default::default();
man.render(&mut buffer)?;

write(out_dir.join("little_boxes.1"), buffer)?;

// Generate completions
for &shell in Shell::value_variants() {
generate_to(shell, &mut cmd, "little_boxes", out_dir.clone())?;
}

Ok(())
}
1 change: 1 addition & 0 deletions vendor/clap_complete/.cargo-checksum.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"files":{"Cargo.lock":"2fdc77136db7765af2187b4624e8c33af011c118a4806d969860f43daafa2da3","Cargo.toml":"034b220a134f3393ceaa0c108e2aab6e8e8f7287f50c575a40bed6a44af3a552","LICENSE-APACHE":"c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4","LICENSE-MIT":"0d687e1f07b58fe68bda74668ff6326125e5e5efa184cce755cd84ac535b7058","README.md":"33c6688753aec0ce9a532642abec98aaed90bb8bbad85a3430f58579e0f19a26","examples/completion-derive.rs":"9df678ff1b67b7e8e829d53d983960429eb809aac4e72f4c5415a59cee8684a6","examples/completion.rs":"d81c0281ae87280d40381e468c0fa2bb4d8751022fdfd0d11ed9d54598e18d8d","examples/dynamic.rs":"0fa838cd9b5f406b5adb467827be43120752673f8d8eca011a01a3e91f26678b","examples/exhaustive.rs":"3acc2b4c1591b0488c721fbff4bb4bbd8d71b58ce3534d82d41f6b2977aff054","src/dynamic/completer.rs":"068e9996f5b3a5f0da6a1ad491a3c08b3b012c117c6f440047c13d035f091e0f","src/dynamic/mod.rs":"22e7f8464b9b9de49ff0236a0a03d86c4aba252b06203f42cb008b42cdcac668","src/dynamic/shells/bash.rs":"a9b10718b4d4739a3aa754adfb57bee3f6148d521d5730f7db96f410bc683788","src/dynamic/shells/fish.rs":"3cdd624d326ccbf48cace8d235af21b8c47457023df428c89fada264ae47cf61","src/dynamic/shells/mod.rs":"0e8a43f8f098e67d88ac5bb64cbe35a2e69c5b9f283982a84b2aeb941c8d1cd9","src/dynamic/shells/shell.rs":"3ac94923495c8d93a41cc105f8e8123edcb78bc6f5645a79b3b22ba5e6917b87","src/generator/mod.rs":"4d594164815da2ec019d9844b91372346e3dd333001b97e4f866530615d58d39","src/generator/utils.rs":"3790b21947a248d8babe19c0ebe746f39880c0b21303a60d37a16034cc1e17ec","src/lib.rs":"429c094c4e3ee9cf8a54d2ac58a2a4a879961202b5fc86c39bac7b32ce41547e","src/macros.rs":"8445231263f03893ab3806e3f50747113bf8d638bd81e2a6bf33c9a0df224421","src/shells/bash.rs":"b6d0cd477cefdf52919e7a983bdb64e2e62811dba2a9fd2293d4f51b089adf52","src/shells/elvish.rs":"b9cdf0fd4b7adf93e8d3c99e22c6d7077963e4b9b47a250399063002eb398327","src/shells/fish.rs":"822833d88225bf3a4a15e6a48b65bcb0bf236cd6dd9ae6016159e90fa15acd8b","src/shells/mod.rs":"002352299be1ece75540e7b1502120590f4635f69a925b19484d272bd5491505","src/shells/powershell.rs":"f35d14783f9111d0f2c48f07b94ab50bbbd43ff1e1d1ed20a09de57ccb433936","src/shells/shell.rs":"4dd9df0bd1f371da370c66808d16ad00a045ba3b997844b1164518b094bba951","src/shells/zsh.rs":"1d4304ed282dc78aa677848a037df8189239b16c3f2408aa63741a9ae28931bf"},"package":"885e4d7d5af40bfb99ae6f9433e292feac98d452dcb3ec3d25dfe7552b77da8c"}
Loading

0 comments on commit 0698d28

Please sign in to comment.