summaryrefslogtreecommitdiffstats
path: root/sqv/build.rs
diff options
context:
space:
mode:
authorNora Widdecke <nora@sequoia-pgp.org>2021-07-08 15:31:44 +0200
committerNora Widdecke <nora@sequoia-pgp.org>2021-07-09 21:54:51 +0200
commitc84b096add1d05afc41cc94b35a9db15bac0afea (patch)
tree3bcf860de8a5ea56ca55a69ca7dbebbfdd378964 /sqv/build.rs
parentc1a03f229e61402e9418ee31609f1b22cbe13e4a (diff)
sqv: Move to https://gitlab.com/sequoia-pgp/sequoia-sqv
- From this point on, the crate sequoia-sqv will be maintained in its own repository.
Diffstat (limited to 'sqv/build.rs')
-rw-r--r--sqv/build.rs101
1 files changed, 0 insertions, 101 deletions
diff --git a/sqv/build.rs b/sqv/build.rs
deleted file mode 100644
index 921e71ff..00000000
--- a/sqv/build.rs
+++ /dev/null
@@ -1,101 +0,0 @@
-use std::env;
-use std::fs;
-use std::io::{self, Write};
-use clap::Shell;
-
-mod sqv_cli {
- include!("src/sqv_cli.rs");
-}
-
-fn main() {
- println!("cargo:rerun-if-changed=build.rs");
-
- // XXX: Revisit once
- // https://github.com/rust-lang/rust/issues/44732 is stabilized.
-
- let mut sqv = sqv_cli::configure(clap::App::new("sqv").set_term_width(80));
- let mut main = fs::File::create("src/sqv-usage.rs").unwrap();
- dump_help(&mut main,
- &mut sqv,
- vec![],
- "#").unwrap();
-
- writeln!(main, "\n#![doc(html_favicon_url = \"https://docs.sequoia-pgp.org/favicon.png\")]")
- .unwrap();
- writeln!(main, "#![doc(html_logo_url = \"https://docs.sequoia-pgp.org/logo.svg\")]")
- .unwrap();
- writeln!(main, "\ninclude!(\"sqv.rs\");").unwrap();
-
- let outdir = match env::var_os("CARGO_TARGET_DIR") {
- None => return,
- Some(outdir) => outdir,
- };
- fs::create_dir_all(&outdir).unwrap();
- let mut sqv = sqv_cli::build();
- for shell in &[Shell::Bash, Shell::Fish, Shell::Zsh, Shell::PowerShell,
- Shell::Elvish] {
- sqv.gen_completions("sqv", *shell, &outdir);
- }
-}
-
-fn dump_help(sink: &mut dyn io::Write,
- sqv: &mut clap::App,
- cmd: Vec<String>,
- heading: &str)
- -> io::Result<()>
-{
-
- if cmd.is_empty() {
- writeln!(sink, "//! A command-line frontend for Sequoia.")?;
- writeln!(sink, "//!")?;
- writeln!(sink, "//! # Usage")?;
- } else {
- writeln!(sink, "//!")?;
- writeln!(sink, "//! {} Subcommand {}", heading, cmd.join(" "))?;
- }
-
- writeln!(sink, "//!")?;
-
- let args = std::iter::once("sqv")
- .chain(cmd.iter().map(|s| s.as_str()))
- .chain(std::iter::once("--help"))
- .collect::<Vec<_>>();
-
- let help = sqv.get_matches_from_safe_borrow(&args)
- .unwrap_err().to_string();
-
- writeln!(sink, "//! ```text")?;
- for line in help.trim_end().split('\n').skip(1) {
- if line.is_empty() {
- writeln!(sink, "//!")?;
- } else {
- writeln!(sink, "//! {}", line.trim_end())?;
- }
- }
- writeln!(sink, "//! ```")?;
-
- // Recurse.
- let mut found_subcommands = false;
- for subcmd in help.split('\n').filter_map(move |line| {
- if line == "SUBCOMMANDS:" {
- found_subcommands = true;
- None
- } else if found_subcommands {
- if line.chars().nth(4).map(|c| ! c.is_ascii_whitespace())
- .unwrap_or(false)
- {
- line.trim_start().split(' ').next()
- } else {
- None
- }
- } else {
- None
- }
- }).filter(|subcmd| *subcmd != "help") {
- let mut c = cmd.clone();
- c.push(subcmd.into());
- dump_help(sink, sqv, c, &format!("{}#", heading))?;
- }
-
- Ok(())
-}