deps: update dependencies and add nix flake

This commit is contained in:
LordMZTE 2024-08-03 10:45:03 +02:00
parent 9968bb0068
commit eb551b867c
Signed by: LordMZTE
GPG key ID: B64802DC33A64FF6
8 changed files with 1888 additions and 30 deletions

5
.cargo/config.toml Normal file
View file

@ -0,0 +1,5 @@
[registry]
default = "mzte"
[registries.mzte]
index = "sparse+https://git.mzte.de/api/packages/LordMZTE/cargo/"

1
.gitignore vendored
View file

@ -1,5 +1,4 @@
/target
.idea
*.lock
*.iml
.vscode

1744
Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -7,28 +7,25 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
base64 = "0.13.0"
crossterm = "0.25.0"
image = "0.24.3"
itertools = "0.10.3"
miette = { version = "5.3.0", features = ["fancy"] }
serde_json = "1.0.83"
smart-default = "0.6.0"
termcolor = "1.1.3"
trust-dns-resolver = { version = "0.21.2", features = ["tokio-runtime"] }
unicode-width = "0.1.9"
viuer = "0.6.1"
serde = { version = "1.0.143", features = ["derive"] }
tracing-subscriber = "0.3.15"
tracing = "0.1.36"
clap = { version = "3.2.17", features = ["derive"] }
[dependencies.async-minecraft-ping]
git = "https://github.com/LordMZTE/async-minecraft-ping.git"
tag = "v0.4.0"
base64 = "0.22.1"
crossterm = "0.28.1"
image = "0.24"
itertools = "0.13.0"
miette = { version = "7.2.0", features = ["fancy"] }
serde_json = "1.0.122"
smart-default = "0.7.1"
termcolor = "1.4.1"
trust-dns-resolver = { version = "0.23.2", features = ["tokio-runtime"] }
unicode-width = "0.1.13"
viuer = "0.7.1"
serde = { version = "1.0.204", features = ["derive"] }
tracing-subscriber = "0.3.18"
tracing = "0.1.40"
clap = { version = "4.5.13", features = ["derive"] }
async-minecraft-ping = { version = "0.4.0", registry = "mzte" }
[dependencies.tokio]
version = "1.20.1"
version = "1.39.2"
features = ["rt-multi-thread", "macros", "time"]
[features]

78
flake.lock Normal file
View file

@ -0,0 +1,78 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1722415718,
"narHash": "sha256-5US0/pgxbMksF92k1+eOa8arJTJiPvsdZj9Dl+vJkM4=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "c3392ad349a5227f4a3464dce87bcc5046692fce",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-sparseprotocol": {
"locked": {
"lastModified": 1713361369,
"narHash": "sha256-fcPSCr5O/uOLI1asjQ9ShYs72erxeR0CBPoUymgyTIc=",
"owner": "rayanpiro",
"repo": "nixpkgs",
"rev": "e6dc0fb1a1e4d191fd7f663cb1cbf93fa7f43609",
"type": "github"
},
"original": {
"owner": "rayanpiro",
"ref": "sparse-protocol",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"nixpkgs-sparseprotocol": "nixpkgs-sparseprotocol",
"utils": "utils"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

36
flake.nix Normal file
View file

@ -0,0 +1,36 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
utils.url = "github:numtide/flake-utils";
nixpkgs-sparseprotocol.url = "github:rayanpiro/nixpkgs?ref=sparse-protocol";
};
outputs = { self, nixpkgs, utils, nixpkgs-sparseprotocol }: utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
in
rec {
packages.default = (import nixpkgs-sparseprotocol { inherit system; }).rustPlatform.buildRustPackage {
pname = "mcstat";
version = "0.1.0";
src = ./.;
cargoLock = {
lockFile = ./Cargo.lock;
extraRegistries."sparse+https://git.mzte.de/api/packages/LordMZTE/cargo/" =
"https://git.mzte.de/api/packages/LordMZTE/cargo/api/v1/crates";
};
};
devShells.default = pkgs.mkShell {
inputsFrom = [ packages.default ];
nativeBuildInputs = with pkgs; [
cargo
rustc
];
RUST_SRC_PATH = "${pkgs.rustPlatform.rustcSrc}/library";
};
});
}

View file

@ -1,5 +1,6 @@
use crate::output::Table;
use async_minecraft_ping::StatusResponse;
use base64::{prelude::BASE64_STANDARD, Engine};
use image::{DynamicImage, ImageFormat};
use itertools::Itertools;
use miette::{bail, miette, IntoDiagnostic, WrapErr};
@ -135,7 +136,8 @@ pub fn parse_base64_image(data: String) -> miette::Result<DynamicImage> {
image_format
)
})?;
let data = base64::decode(data)
let data = BASE64_STANDARD
.decode(data)
.into_diagnostic()
.wrap_err("Failed to decode base64 image data")?;
image::load(Cursor::new(data), format)

View file

@ -1,18 +1,15 @@
use async_minecraft_ping::{ConnectionConfig, ServerDescription, StatusResponse};
use clap::Parser;
use clap::{ArgAction, Parser};
use itertools::Itertools;
use miette::{IntoDiagnostic, WrapErr};
use time::Duration;
use tokio::time;
use mcstat::{
get_table,
none_if_empty,
get_table, none_if_empty,
output::{McFormatContent, Table},
parse_base64_image,
resolve_address,
EitherStatusResponse,
parse_base64_image, resolve_address, EitherStatusResponse,
};
use tracing::{info, Level};
@ -57,8 +54,8 @@ struct Opt {
size: Option<u32>,
/// use verbose logging
#[clap(long, short, parse(from_occurrences))]
verbose: u32,
#[clap(long, short, action = ArgAction::Count)]
verbose: u8,
}
impl Opt {