mirror of
https://github.com/LordMZTE/mcstat.git
synced 2024-05-18 06:49:45 +02:00
generate completions for mcstat
This commit is contained in:
parent
8505225e1a
commit
71d3f4e5ee
|
@ -14,9 +14,16 @@ clap = { version = "^2.33", features = ["yaml"] }
|
||||||
image = "0.23.9"
|
image = "0.23.9"
|
||||||
image-base64 = "0.1.0"
|
image-base64 = "0.1.0"
|
||||||
itertools = "0.9.0"
|
itertools = "0.9.0"
|
||||||
|
lazy_static = "1.4.0"
|
||||||
serde_json = "1.0.58"
|
serde_json = "1.0.58"
|
||||||
smart-default = "0.6.0"
|
smart-default = "0.6.0"
|
||||||
term_size = "0.3.2"
|
term_size = "0.3.2"
|
||||||
termcolor = "1"
|
termcolor = "1"
|
||||||
tokio = { version = "0.2.22", features = ["full"] }
|
tokio = { version = "0.2.22", features = ["full"] }
|
||||||
unicode-width = "0.1.8"
|
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]
|
#[macro_use]
|
||||||
extern crate smart_default;
|
extern crate smart_default;
|
||||||
|
|
||||||
|
use crate::output::Table;
|
||||||
use asciify::AsciiBuilder;
|
use asciify::AsciiBuilder;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use crate::output::Table;
|
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
|
|
||||||
pub mod output;
|
pub mod output;
|
||||||
|
|
|
@ -3,7 +3,6 @@ use std::io::Cursor;
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
use asciify::AsciiBuilder;
|
use asciify::AsciiBuilder;
|
||||||
use async_minecraft_ping::{ConnectionConfig, ServerDescription, StatusResponse};
|
use async_minecraft_ping::{ConnectionConfig, ServerDescription, StatusResponse};
|
||||||
use clap::{load_yaml, App};
|
|
||||||
use image::ImageFormat;
|
use image::ImageFormat;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use termcolor::{Buffer, BufferWriter, ColorChoice, WriteColor};
|
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};
|
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
|
/// this message is used if getting a value from the arguments fails
|
||||||
const ARGUMENT_FAIL_MESSAGE: &str = "failed to get value from args";
|
const ARGUMENT_FAIL_MESSAGE: &str = "failed to get value from args";
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<()> {
|
async fn main() -> Result<()> {
|
||||||
let yaml = load_yaml!("args.yml");
|
let matches = cli::get_app().get_matches();
|
||||||
let matches = App::from_yaml(yaml).get_matches();
|
|
||||||
|
|
||||||
// region Network
|
// region Network
|
||||||
let mut ip = matches
|
let mut ip = matches
|
||||||
|
|
Loading…
Reference in a new issue