generate completions for mcstat
This commit is contained in:
parent
8505225e1a
commit
71d3f4e5ee
5 changed files with 44 additions and 4 deletions
|
@ -14,9 +14,16 @@ clap = { version = "^2.33", features = ["yaml"] }
|
|||
image = "0.23.9"
|
||||
image-base64 = "0.1.0"
|
||||
itertools = "0.9.0"
|
||||
lazy_static = "1.4.0"
|
||||
serde_json = "1.0.58"
|
||||
smart-default = "0.6.0"
|
||||
term_size = "0.3.2"
|
||||
termcolor = "1"
|
||||
tokio = { version = "0.2.22", features = ["full"] }
|
||||
unicode-width = "0.1.8"
|
||||
yaml-rust = "0.3.5"
|
||||
|
||||
[build-dependencies]
|
||||
clap = "2.33.3"
|
||||
lazy_static = "1.4.0"
|
||||
yaml-rust = "0.3.5"
|
||||
|
|
19
build.rs
Normal file
19
build.rs
Normal file
|
@ -0,0 +1,19 @@
|
|||
use clap::Shell;
|
||||
use std::{env, str::FromStr};
|
||||
|
||||
include!("src/cli.rs");
|
||||
|
||||
fn main() {
|
||||
let outdir = match env::var_os("OUT_DIR") {
|
||||
None => return,
|
||||
Some(d) => d,
|
||||
};
|
||||
|
||||
let mut app = get_app();
|
||||
for s in Shell::variants()
|
||||
.iter()
|
||||
.map(|v| Shell::from_str(v).unwrap())
|
||||
{
|
||||
app.gen_completions("mcstat", s, &outdir);
|
||||
}
|
||||
}
|
14
src/cli.rs
Normal file
14
src/cli.rs
Normal file
|
@ -0,0 +1,14 @@
|
|||
use clap::{App, YamlLoader};
|
||||
use lazy_static::lazy_static;
|
||||
use yaml_rust::Yaml;
|
||||
|
||||
lazy_static! {
|
||||
static ref YAML: Yaml = YamlLoader::load_from_str(include_str!("args.yml"))
|
||||
.unwrap()
|
||||
.pop()
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
pub fn get_app() -> App<'static, 'static> {
|
||||
App::from_yaml(&YAML)
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
#[macro_use]
|
||||
extern crate smart_default;
|
||||
|
||||
use crate::output::Table;
|
||||
use asciify::AsciiBuilder;
|
||||
use itertools::Itertools;
|
||||
use crate::output::Table;
|
||||
use std::io::Cursor;
|
||||
|
||||
pub mod output;
|
||||
|
|
|
@ -3,7 +3,6 @@ use std::io::Cursor;
|
|||
use anyhow::{anyhow, Context, Result};
|
||||
use asciify::AsciiBuilder;
|
||||
use async_minecraft_ping::{ConnectionConfig, ServerDescription, StatusResponse};
|
||||
use clap::{load_yaml, App};
|
||||
use image::ImageFormat;
|
||||
use itertools::Itertools;
|
||||
use termcolor::{Buffer, BufferWriter, ColorChoice, WriteColor};
|
||||
|
@ -12,13 +11,14 @@ use tokio::time;
|
|||
|
||||
use mcstat::{get_table, none_if_empty, output::Table, remove_formatting, AsciiConfig};
|
||||
|
||||
mod cli;
|
||||
|
||||
/// this message is used if getting a value from the arguments fails
|
||||
const ARGUMENT_FAIL_MESSAGE: &str = "failed to get value from args";
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
let yaml = load_yaml!("args.yml");
|
||||
let matches = App::from_yaml(yaml).get_matches();
|
||||
let matches = cli::get_app().get_matches();
|
||||
|
||||
// region Network
|
||||
let mut ip = matches
|
||||
|
|
Loading…
Reference in a new issue