~zethra/stargazer

ref: 69199eabd34a2b733f9e4876ad0f8fca82a6d002 stargazer/build.rs -rw-r--r-- 1.4 KiB
69199eab — Ben Aaron Goldberg FIX 19: IPv6 listeners no longer conflict with IPv4 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// A Gemini Server
// Copyright (C) 2020 Ben Aaron Goldberg <ben@benaaron.dev>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public
// License along with this program. If not, see
// <https://www.gnu.org/licenses/>.

use structopt::clap::Shell;

use std::path::Path;
use std::fs;

include!("src/cli.rs");

const SHELLS: [Shell; 5] = [
    Shell::Bash,
    Shell::Zsh,
    Shell::Fish,
    Shell::PowerShell,
    Shell::Elvish,
];

fn main() -> std::io::Result<()> {
    let out_dir = match std::env::var_os("OUT_DIR") {
        None => return Ok(()),
        Some(out_dir) => out_dir,
    };
    let mut path = Path::new(&out_dir).to_owned();
    path.pop();
    path.pop();
    path.pop();
    path.push("completions");
    fs::create_dir_all(&path)?;
    let mut args = Args::clap();
    for shell in &SHELLS {
        args.gen_completions("stargazer", *shell, &path);
    }
    Ok(())
}