From 80f6b8799189b431c50301cd5a09a58e347507b4 Mon Sep 17 00:00:00 2001 From: Cain <75994858+cainthebest@users.noreply.github.com> Date: Mon, 16 Oct 2023 23:20:47 +0100 Subject: [PATCH 1/9] refator: copy cli into mono --- Cargo.toml | 40 ++------ crates/cli/Cargo.toml | 22 +++++ crates/cli/src/error.rs | 16 ++++ crates/cli/src/key.rs | 93 +++++++++++++++++++ crates/cli/src/main.rs | 73 +++++++++++++++ crates/lib/Cargo.toml | 34 +++++++ {examples => crates/lib/examples}/generic.rs | 0 .../lib/examples}/minecraft.rs | 0 .../lib/examples}/teamfortress2.rs | 0 .../examples}/valve_master_server_query.rs | 0 {src => crates/lib/src}/buffer.rs | 0 {src => crates/lib/src}/errors/error.rs | 0 {src => crates/lib/src}/errors/kind.rs | 0 {src => crates/lib/src}/errors/mod.rs | 0 {src => crates/lib/src}/errors/result.rs | 0 .../lib/src}/games/battalion1944.rs | 0 {src => crates/lib/src}/games/definitions.rs | 0 {src => crates/lib/src}/games/ffow.rs | 0 {src => crates/lib/src}/games/gamespy.rs | 0 {src => crates/lib/src}/games/jc2m.rs | 0 {src => crates/lib/src}/games/minecraft.rs | 0 {src => crates/lib/src}/games/mod.rs | 0 {src => crates/lib/src}/games/quake.rs | 0 {src => crates/lib/src}/games/theship.rs | 0 {src => crates/lib/src}/games/valve.rs | 0 {src => crates/lib/src}/lib.rs | 0 .../lib/src}/protocols/gamespy/common.rs | 0 .../lib/src}/protocols/gamespy/mod.rs | 0 .../src}/protocols/gamespy/protocols/mod.rs | 0 .../protocols/gamespy/protocols/one/mod.rs | 0 .../gamespy/protocols/one/protocol.rs | 0 .../protocols/gamespy/protocols/one/types.rs | 0 .../protocols/gamespy/protocols/three/mod.rs | 0 .../gamespy/protocols/three/protocol.rs | 0 .../gamespy/protocols/three/types.rs | 0 .../protocols/gamespy/protocols/two/mod.rs | 0 .../gamespy/protocols/two/protocol.rs | 0 .../protocols/gamespy/protocols/two/types.rs | 0 .../lib/src}/protocols/minecraft/mod.rs | 0 .../protocols/minecraft/protocol/bedrock.rs | 0 .../src}/protocols/minecraft/protocol/java.rs | 0 .../minecraft/protocol/legacy_v1_3.rs | 0 .../minecraft/protocol/legacy_v1_5.rs | 0 .../minecraft/protocol/legacy_v1_6.rs | 0 .../src}/protocols/minecraft/protocol/mod.rs | 0 .../lib/src}/protocols/minecraft/types.rs | 0 {src => crates/lib/src}/protocols/mod.rs | 0 .../lib/src}/protocols/quake/client.rs | 0 .../lib/src}/protocols/quake/mod.rs | 0 .../lib/src}/protocols/quake/one.rs | 0 .../lib/src}/protocols/quake/three.rs | 0 .../lib/src}/protocols/quake/two.rs | 0 .../lib/src}/protocols/quake/types.rs | 0 {src => crates/lib/src}/protocols/types.rs | 0 .../lib/src}/protocols/valve/mod.rs | 0 .../lib/src}/protocols/valve/protocol.rs | 0 .../lib/src}/protocols/valve/types.rs | 0 {src => crates/lib/src}/services/mod.rs | 0 .../src}/services/valve_master_server/mod.rs | 0 .../services/valve_master_server/service.rs | 0 .../services/valve_master_server/types.rs | 0 {src => crates/lib/src}/socket.rs | 0 {src => crates/lib/src}/utils.rs | 0 63 files changed, 244 insertions(+), 34 deletions(-) create mode 100644 crates/cli/Cargo.toml create mode 100644 crates/cli/src/error.rs create mode 100644 crates/cli/src/key.rs create mode 100644 crates/cli/src/main.rs create mode 100644 crates/lib/Cargo.toml rename {examples => crates/lib/examples}/generic.rs (100%) rename {examples => crates/lib/examples}/minecraft.rs (100%) rename {examples => crates/lib/examples}/teamfortress2.rs (100%) rename {examples => crates/lib/examples}/valve_master_server_query.rs (100%) rename {src => crates/lib/src}/buffer.rs (100%) rename {src => crates/lib/src}/errors/error.rs (100%) rename {src => crates/lib/src}/errors/kind.rs (100%) rename {src => crates/lib/src}/errors/mod.rs (100%) rename {src => crates/lib/src}/errors/result.rs (100%) rename {src => crates/lib/src}/games/battalion1944.rs (100%) rename {src => crates/lib/src}/games/definitions.rs (100%) rename {src => crates/lib/src}/games/ffow.rs (100%) rename {src => crates/lib/src}/games/gamespy.rs (100%) rename {src => crates/lib/src}/games/jc2m.rs (100%) rename {src => crates/lib/src}/games/minecraft.rs (100%) rename {src => crates/lib/src}/games/mod.rs (100%) rename {src => crates/lib/src}/games/quake.rs (100%) rename {src => crates/lib/src}/games/theship.rs (100%) rename {src => crates/lib/src}/games/valve.rs (100%) rename {src => crates/lib/src}/lib.rs (100%) rename {src => crates/lib/src}/protocols/gamespy/common.rs (100%) rename {src => crates/lib/src}/protocols/gamespy/mod.rs (100%) rename {src => crates/lib/src}/protocols/gamespy/protocols/mod.rs (100%) rename {src => crates/lib/src}/protocols/gamespy/protocols/one/mod.rs (100%) rename {src => crates/lib/src}/protocols/gamespy/protocols/one/protocol.rs (100%) rename {src => crates/lib/src}/protocols/gamespy/protocols/one/types.rs (100%) rename {src => crates/lib/src}/protocols/gamespy/protocols/three/mod.rs (100%) rename {src => crates/lib/src}/protocols/gamespy/protocols/three/protocol.rs (100%) rename {src => crates/lib/src}/protocols/gamespy/protocols/three/types.rs (100%) rename {src => crates/lib/src}/protocols/gamespy/protocols/two/mod.rs (100%) rename {src => crates/lib/src}/protocols/gamespy/protocols/two/protocol.rs (100%) rename {src => crates/lib/src}/protocols/gamespy/protocols/two/types.rs (100%) rename {src => crates/lib/src}/protocols/minecraft/mod.rs (100%) rename {src => crates/lib/src}/protocols/minecraft/protocol/bedrock.rs (100%) rename {src => crates/lib/src}/protocols/minecraft/protocol/java.rs (100%) rename {src => crates/lib/src}/protocols/minecraft/protocol/legacy_v1_3.rs (100%) rename {src => crates/lib/src}/protocols/minecraft/protocol/legacy_v1_5.rs (100%) rename {src => crates/lib/src}/protocols/minecraft/protocol/legacy_v1_6.rs (100%) rename {src => crates/lib/src}/protocols/minecraft/protocol/mod.rs (100%) rename {src => crates/lib/src}/protocols/minecraft/types.rs (100%) rename {src => crates/lib/src}/protocols/mod.rs (100%) rename {src => crates/lib/src}/protocols/quake/client.rs (100%) rename {src => crates/lib/src}/protocols/quake/mod.rs (100%) rename {src => crates/lib/src}/protocols/quake/one.rs (100%) rename {src => crates/lib/src}/protocols/quake/three.rs (100%) rename {src => crates/lib/src}/protocols/quake/two.rs (100%) rename {src => crates/lib/src}/protocols/quake/types.rs (100%) rename {src => crates/lib/src}/protocols/types.rs (100%) rename {src => crates/lib/src}/protocols/valve/mod.rs (100%) rename {src => crates/lib/src}/protocols/valve/protocol.rs (100%) rename {src => crates/lib/src}/protocols/valve/types.rs (100%) rename {src => crates/lib/src}/services/mod.rs (100%) rename {src => crates/lib/src}/services/valve_master_server/mod.rs (100%) rename {src => crates/lib/src}/services/valve_master_server/service.rs (100%) rename {src => crates/lib/src}/services/valve_master_server/types.rs (100%) rename {src => crates/lib/src}/socket.rs (100%) rename {src => crates/lib/src}/utils.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index 4949cc1e..8d744031 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,34 +1,6 @@ -[package] -name = "gamedig" -version = "0.4.1" -edition = "2021" -authors = [ - "rust-GameDig contributors [https://github.com/gamedig/rust-gamedig/contributors]", - "node-GameDig contributors [https://github.com/gamedig/node-gamedig/contributors]", -] -license = "MIT" -description = "Query game servers and not only." -homepage = "https://github.com/gamedig/rust-gamedig" -documentation = "https://docs.rs/gamedig/latest/gamedig/" -repository = "https://github.com/gamedig/rust-gamedig" -readme = "README.md" -keywords = ["server", "query", "game", "check", "status"] -rust-version = "1.65.0" -categories = ["parser-implementations", "parsing", "network-programming", "encoding"] - -[features] -default = ["games", "services", "game_defs"] -games = [] -services = [] -game_defs = ["dep:phf", "games"] -serde = ["dep:serde", "serde/derive"] - -[dependencies] -byteorder = "1.5" -bzip2-rs = "0.1" -crc32fast = "1.3" -serde_json = "1.0" - -serde = { version = "1.0", optional = true } - -phf = { version = "0.11", optional = true, features = ["macros"] } +[workspace] +name = "gamedig-workspace" +members = [ + "crates/cli", + "crates/lib", +] \ No newline at end of file diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml new file mode 100644 index 00000000..a93c1b50 --- /dev/null +++ b/crates/cli/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "gamedig-cli" +authors = ["rust-GameDig contributors [https://github.com/gamedig/rust-gamedig/contributors]"] +description = "A command line interface for gamedig" +license = "MIT" +version = "0.4.1" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +clap = { version = "4.1.11", features = ["derive"] } +gamedig = { version = "*", path = "../lib" } +strum = "0.25.0" +strum_macros = "0.24.3" +thiserror = "1.0.43" + +[profile.release] +opt-level = 3 +debug = false +rpath = true +lto = true \ No newline at end of file diff --git a/crates/cli/src/error.rs b/crates/cli/src/error.rs new file mode 100644 index 00000000..882de15e --- /dev/null +++ b/crates/cli/src/error.rs @@ -0,0 +1,16 @@ +pub type Result = std::result::Result; + +#[derive(thiserror::Error, Debug)] +pub enum Error { + #[error("IO Error: {0}")] + Io(#[from] std::io::Error), + + #[error("Clap Error: {0}")] + Clap(#[from] clap::Error), + + #[error("Gamedig Error: {0}")] + Gamedig(#[from] gamedig::errors::GDError), + + #[error("Strum Error: {0}")] + Strum(#[from] strum::ParseError), +} \ No newline at end of file diff --git a/crates/cli/src/key.rs b/crates/cli/src/key.rs new file mode 100644 index 00000000..a1c19ba5 --- /dev/null +++ b/crates/cli/src/key.rs @@ -0,0 +1,93 @@ +use strum_macros::{Display, EnumString}; + +#[derive(EnumString, Display, Debug, Clone)] +pub enum Game { + #[strum(serialize = "aliens")] + AlienSwarm, + #[strum(serialize = "aoc")] + AgeOfChivalry, + #[strum(serialize = "arma2oa")] + ARMA2OperationArrowhead, + #[strum(serialize = "ase")] + ARKSurvivalEvolved, + #[strum(serialize = "asrd")] + AlienSwarmReactiveDrop, + #[strum(serialize = "avorion")] + Avorion, + #[strum(serialize = "bat1944")] + Battalion1944, + #[strum(serialize = "bb2")] + BrainBread2, + #[strum(serialize = "bf1942")] + Battlefield1942, + #[strum(serialize = "bm")] + BlackMesa, + #[strum(serialize = "bo")] + BallisticOverkill, + #[strum(serialize = "ccure")] + CodenameCURE, + #[strum(serialize = "cosu")] + ColonySurvival, + #[strum(serialize = "cs")] + CounterStrike, + #[strum(serialize = "cscz")] + CounterStrikeConditionZero, + #[strum(serialize = "csgo")] + CounterStrikeGlobalOffensive, + #[strum(serialize = "css")] + CounterStrikeSource, + #[strum(serialize = "dod")] + DayOfDefeat, + #[strum(serialize = "dods")] + DayOfDefeatSource, + #[strum(serialize = "doi")] + DayOfInfamy, + #[strum(serialize = "dst")] + DontStarveTogether, + #[strum(serialize = "gm")] + GarrysMod, + #[strum(serialize = "hl2dm")] + HalfLife2Deathmatch, + #[strum(serialize = "hldms")] + HalfLifeDeathmatchSource, + #[strum(serialize = "ins")] + Insurgency, + #[strum(serialize = "insmic")] + InsurgencyModernInfantryCombat, + #[strum(serialize = "inss")] + InsurgencySandstorm, + #[strum(serialize = "l4d")] + Left4Dead, + #[strum(serialize = "l4d2")] + Left4Dead2, + #[strum(serialize = "mc")] + Minecraft, + #[strum(serialize = "ohd")] + OperationHarshDoorstop, + #[strum(serialize = "onset")] + Onset, + #[strum(serialize = "pz")] + ProjectZomboid, + #[strum(serialize = "ror2")] + RiskOfRain2, + #[strum(serialize = "rust")] + Rust, + #[strum(serialize = "sc")] + SvenCoOp, + #[strum(serialize = "sdtd")] + SevenDaysToDie, + #[strum(serialize = "tf")] + TeamFortress, + #[strum(serialize = "tf2")] + TeamFortress2, + #[strum(serialize = "tfc")] + TeamFortressClassic, + #[strum(serialize = "ts")] + TheShip, + #[strum(serialize = "unturned")] + Unturned, + #[strum(serialize = "ut")] + UnrealTournament, + #[strum(serialize = "vr")] + VRising, +} \ No newline at end of file diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs new file mode 100644 index 00000000..479ecfbf --- /dev/null +++ b/crates/cli/src/main.rs @@ -0,0 +1,73 @@ +mod error; +mod key; + +use self::{error::Result, key::Game}; + +use clap::Parser; +use gamedig::games::*; + +#[derive(Parser)] +#[command(author, version, about)] +struct Cli { + #[arg(short, long)] + game: Game, + + #[arg(short, long)] + ip: String, + + #[arg(short, long)] + port: u16, +} + +#[rustfmt::skip] +fn main() -> Result<()> { + let args = Cli::parse(); + + match args.game { + Game::AlienSwarm => Ok(println!("{:#?}", aliens::query(&args.ip, Some(args.port))?)), + Game::AgeOfChivalry => Ok(println!("{:#?}", aoc::query(&args.ip, Some(args.port))?)), + Game::ARMA2OperationArrowhead => Ok(println!("{:#?}", arma2oa::query(&args.ip, Some(args.port))?)), + Game::ARKSurvivalEvolved => Ok(println!("{:#?}", ase::query(&args.ip, Some(args.port))?)), + Game::AlienSwarmReactiveDrop => Ok(println!("{:#?}", asrd::query(&args.ip, Some(args.port))?)), + Game::Avorion => Ok(println!("{:#?}", avorion::query(&args.ip, Some(args.port))?)), + Game::Battalion1944 => Ok(println!("{:#?}", bat1944::query(&args.ip, Some(args.port))?)), + Game::BrainBread2 => Ok(println!("{:#?}", bb2::query(&args.ip, Some(args.port))?)), + Game::Battlefield1942 => Ok(println!("{:#?}", bf1942::query(&args.ip, Some(args.port))?)), + Game::BlackMesa => Ok(println!("{:#?}", bm::query(&args.ip, Some(args.port))?)), + Game::BallisticOverkill => Ok(println!("{:#?}", bo::query(&args.ip, Some(args.port))?)), + Game::CodenameCURE => Ok(println!("{:#?}", ccure::query(&args.ip, Some(args.port))?)), + Game::ColonySurvival => Ok(println!("{:#?}", cosu::query(&args.ip, Some(args.port))?)), + Game::CounterStrike => Ok(println!("{:#?}", cs::query(&args.ip, Some(args.port))?)), + Game::CounterStrikeConditionZero => Ok(println!("{:#?}", cscz::query(&args.ip, Some(args.port))?)), + Game::CounterStrikeGlobalOffensive => Ok(println!("{:#?}", csgo::query(&args.ip, Some(args.port))?)), + Game::CounterStrikeSource => Ok(println!("{:#?}", css::query(&args.ip, Some(args.port))?)), + Game::DayOfDefeat => Ok(println!("{:#?}", dod::query(&args.ip, Some(args.port))?)), + Game::DayOfDefeatSource => Ok(println!("{:#?}", dods::query(&args.ip, Some(args.port))?)), + Game::DayOfInfamy => Ok(println!("{:#?}", doi::query(&args.ip, Some(args.port))?)), + Game::DontStarveTogether => Ok(println!("{:#?}", dst::query(&args.ip, Some(args.port))?)), + Game::GarrysMod => Ok(println!("{:#?}", gm::query(&args.ip, Some(args.port))?)), + Game::HalfLife2Deathmatch => Ok(println!("{:#?}", hl2dm::query(&args.ip, Some(args.port))?)), + Game::HalfLifeDeathmatchSource => Ok(println!("{:#?}", hldms::query(&args.ip, Some(args.port))?)), + Game::Insurgency => Ok(println!("{:#?}", ins::query(&args.ip, Some(args.port))?)), + Game::InsurgencyModernInfantryCombat => Ok(println!("{:#?}", insmic::query(&args.ip, Some(args.port))?)), + Game::InsurgencySandstorm => Ok(println!("{:#?}", inss::query(&args.ip, Some(args.port))?)), + Game::Left4Dead => Ok(println!("{:#?}", l4d::query(&args.ip, Some(args.port))?)), + Game::Left4Dead2 => Ok(println!("{:#?}", l4d2::query(&args.ip, Some(args.port))?)), + Game::Minecraft => Ok(println!("{:#?}", mc::query(&args.ip, Some(args.port))?)), + Game::OperationHarshDoorstop => Ok(println!("{:#?}", ohd::query(&args.ip, Some(args.port))?)), + Game::Onset => Ok(println!("{:#?}", onset::query(&args.ip, Some(args.port))?)), + Game::ProjectZomboid => Ok(println!("{:#?}", pz::query(&args.ip, Some(args.port))?)), + Game::RiskOfRain2 => Ok(println!("{:#?}", ror2::query(&args.ip, Some(args.port))?)), + Game::Rust => Ok(println!("{:#?}", rust::query(&args.ip, Some(args.port))?)), + Game::SvenCoOp => Ok(println!("{:#?}", sc::query(&args.ip, Some(args.port))?)), + Game::SevenDaysToDie => Ok(println!("{:#?}", sdtd::query(&args.ip, Some(args.port))?)), + Game::TeamFortress => Ok(println!("{:#?}", tf::query(&args.ip, Some(args.port))?)), + Game::TeamFortress2 => Ok(println!("{:#?}", tf2::query(&args.ip, Some(args.port))?)), + Game::TeamFortressClassic => Ok(println!("{:#?}", tfc::query(&args.ip, Some(args.port))?)), + Game::TheShip => Ok(println!("{:#?}", ts::query(&args.ip, Some(args.port))?)), + Game::Unturned => Ok(println!("{:#?}", unturned::query(&args.ip, Some(args.port))?)), + Game::UnrealTournament => Ok(println!("{:#?}", ut::query(&args.ip, Some(args.port))?)), + Game::VRising => Ok(println!("{:#?}", vr::query(&args.ip, Some(args.port))?)), + + } +} \ No newline at end of file diff --git a/crates/lib/Cargo.toml b/crates/lib/Cargo.toml new file mode 100644 index 00000000..4949cc1e --- /dev/null +++ b/crates/lib/Cargo.toml @@ -0,0 +1,34 @@ +[package] +name = "gamedig" +version = "0.4.1" +edition = "2021" +authors = [ + "rust-GameDig contributors [https://github.com/gamedig/rust-gamedig/contributors]", + "node-GameDig contributors [https://github.com/gamedig/node-gamedig/contributors]", +] +license = "MIT" +description = "Query game servers and not only." +homepage = "https://github.com/gamedig/rust-gamedig" +documentation = "https://docs.rs/gamedig/latest/gamedig/" +repository = "https://github.com/gamedig/rust-gamedig" +readme = "README.md" +keywords = ["server", "query", "game", "check", "status"] +rust-version = "1.65.0" +categories = ["parser-implementations", "parsing", "network-programming", "encoding"] + +[features] +default = ["games", "services", "game_defs"] +games = [] +services = [] +game_defs = ["dep:phf", "games"] +serde = ["dep:serde", "serde/derive"] + +[dependencies] +byteorder = "1.5" +bzip2-rs = "0.1" +crc32fast = "1.3" +serde_json = "1.0" + +serde = { version = "1.0", optional = true } + +phf = { version = "0.11", optional = true, features = ["macros"] } diff --git a/examples/generic.rs b/crates/lib/examples/generic.rs similarity index 100% rename from examples/generic.rs rename to crates/lib/examples/generic.rs diff --git a/examples/minecraft.rs b/crates/lib/examples/minecraft.rs similarity index 100% rename from examples/minecraft.rs rename to crates/lib/examples/minecraft.rs diff --git a/examples/teamfortress2.rs b/crates/lib/examples/teamfortress2.rs similarity index 100% rename from examples/teamfortress2.rs rename to crates/lib/examples/teamfortress2.rs diff --git a/examples/valve_master_server_query.rs b/crates/lib/examples/valve_master_server_query.rs similarity index 100% rename from examples/valve_master_server_query.rs rename to crates/lib/examples/valve_master_server_query.rs diff --git a/src/buffer.rs b/crates/lib/src/buffer.rs similarity index 100% rename from src/buffer.rs rename to crates/lib/src/buffer.rs diff --git a/src/errors/error.rs b/crates/lib/src/errors/error.rs similarity index 100% rename from src/errors/error.rs rename to crates/lib/src/errors/error.rs diff --git a/src/errors/kind.rs b/crates/lib/src/errors/kind.rs similarity index 100% rename from src/errors/kind.rs rename to crates/lib/src/errors/kind.rs diff --git a/src/errors/mod.rs b/crates/lib/src/errors/mod.rs similarity index 100% rename from src/errors/mod.rs rename to crates/lib/src/errors/mod.rs diff --git a/src/errors/result.rs b/crates/lib/src/errors/result.rs similarity index 100% rename from src/errors/result.rs rename to crates/lib/src/errors/result.rs diff --git a/src/games/battalion1944.rs b/crates/lib/src/games/battalion1944.rs similarity index 100% rename from src/games/battalion1944.rs rename to crates/lib/src/games/battalion1944.rs diff --git a/src/games/definitions.rs b/crates/lib/src/games/definitions.rs similarity index 100% rename from src/games/definitions.rs rename to crates/lib/src/games/definitions.rs diff --git a/src/games/ffow.rs b/crates/lib/src/games/ffow.rs similarity index 100% rename from src/games/ffow.rs rename to crates/lib/src/games/ffow.rs diff --git a/src/games/gamespy.rs b/crates/lib/src/games/gamespy.rs similarity index 100% rename from src/games/gamespy.rs rename to crates/lib/src/games/gamespy.rs diff --git a/src/games/jc2m.rs b/crates/lib/src/games/jc2m.rs similarity index 100% rename from src/games/jc2m.rs rename to crates/lib/src/games/jc2m.rs diff --git a/src/games/minecraft.rs b/crates/lib/src/games/minecraft.rs similarity index 100% rename from src/games/minecraft.rs rename to crates/lib/src/games/minecraft.rs diff --git a/src/games/mod.rs b/crates/lib/src/games/mod.rs similarity index 100% rename from src/games/mod.rs rename to crates/lib/src/games/mod.rs diff --git a/src/games/quake.rs b/crates/lib/src/games/quake.rs similarity index 100% rename from src/games/quake.rs rename to crates/lib/src/games/quake.rs diff --git a/src/games/theship.rs b/crates/lib/src/games/theship.rs similarity index 100% rename from src/games/theship.rs rename to crates/lib/src/games/theship.rs diff --git a/src/games/valve.rs b/crates/lib/src/games/valve.rs similarity index 100% rename from src/games/valve.rs rename to crates/lib/src/games/valve.rs diff --git a/src/lib.rs b/crates/lib/src/lib.rs similarity index 100% rename from src/lib.rs rename to crates/lib/src/lib.rs diff --git a/src/protocols/gamespy/common.rs b/crates/lib/src/protocols/gamespy/common.rs similarity index 100% rename from src/protocols/gamespy/common.rs rename to crates/lib/src/protocols/gamespy/common.rs diff --git a/src/protocols/gamespy/mod.rs b/crates/lib/src/protocols/gamespy/mod.rs similarity index 100% rename from src/protocols/gamespy/mod.rs rename to crates/lib/src/protocols/gamespy/mod.rs diff --git a/src/protocols/gamespy/protocols/mod.rs b/crates/lib/src/protocols/gamespy/protocols/mod.rs similarity index 100% rename from src/protocols/gamespy/protocols/mod.rs rename to crates/lib/src/protocols/gamespy/protocols/mod.rs diff --git a/src/protocols/gamespy/protocols/one/mod.rs b/crates/lib/src/protocols/gamespy/protocols/one/mod.rs similarity index 100% rename from src/protocols/gamespy/protocols/one/mod.rs rename to crates/lib/src/protocols/gamespy/protocols/one/mod.rs diff --git a/src/protocols/gamespy/protocols/one/protocol.rs b/crates/lib/src/protocols/gamespy/protocols/one/protocol.rs similarity index 100% rename from src/protocols/gamespy/protocols/one/protocol.rs rename to crates/lib/src/protocols/gamespy/protocols/one/protocol.rs diff --git a/src/protocols/gamespy/protocols/one/types.rs b/crates/lib/src/protocols/gamespy/protocols/one/types.rs similarity index 100% rename from src/protocols/gamespy/protocols/one/types.rs rename to crates/lib/src/protocols/gamespy/protocols/one/types.rs diff --git a/src/protocols/gamespy/protocols/three/mod.rs b/crates/lib/src/protocols/gamespy/protocols/three/mod.rs similarity index 100% rename from src/protocols/gamespy/protocols/three/mod.rs rename to crates/lib/src/protocols/gamespy/protocols/three/mod.rs diff --git a/src/protocols/gamespy/protocols/three/protocol.rs b/crates/lib/src/protocols/gamespy/protocols/three/protocol.rs similarity index 100% rename from src/protocols/gamespy/protocols/three/protocol.rs rename to crates/lib/src/protocols/gamespy/protocols/three/protocol.rs diff --git a/src/protocols/gamespy/protocols/three/types.rs b/crates/lib/src/protocols/gamespy/protocols/three/types.rs similarity index 100% rename from src/protocols/gamespy/protocols/three/types.rs rename to crates/lib/src/protocols/gamespy/protocols/three/types.rs diff --git a/src/protocols/gamespy/protocols/two/mod.rs b/crates/lib/src/protocols/gamespy/protocols/two/mod.rs similarity index 100% rename from src/protocols/gamespy/protocols/two/mod.rs rename to crates/lib/src/protocols/gamespy/protocols/two/mod.rs diff --git a/src/protocols/gamespy/protocols/two/protocol.rs b/crates/lib/src/protocols/gamespy/protocols/two/protocol.rs similarity index 100% rename from src/protocols/gamespy/protocols/two/protocol.rs rename to crates/lib/src/protocols/gamespy/protocols/two/protocol.rs diff --git a/src/protocols/gamespy/protocols/two/types.rs b/crates/lib/src/protocols/gamespy/protocols/two/types.rs similarity index 100% rename from src/protocols/gamespy/protocols/two/types.rs rename to crates/lib/src/protocols/gamespy/protocols/two/types.rs diff --git a/src/protocols/minecraft/mod.rs b/crates/lib/src/protocols/minecraft/mod.rs similarity index 100% rename from src/protocols/minecraft/mod.rs rename to crates/lib/src/protocols/minecraft/mod.rs diff --git a/src/protocols/minecraft/protocol/bedrock.rs b/crates/lib/src/protocols/minecraft/protocol/bedrock.rs similarity index 100% rename from src/protocols/minecraft/protocol/bedrock.rs rename to crates/lib/src/protocols/minecraft/protocol/bedrock.rs diff --git a/src/protocols/minecraft/protocol/java.rs b/crates/lib/src/protocols/minecraft/protocol/java.rs similarity index 100% rename from src/protocols/minecraft/protocol/java.rs rename to crates/lib/src/protocols/minecraft/protocol/java.rs diff --git a/src/protocols/minecraft/protocol/legacy_v1_3.rs b/crates/lib/src/protocols/minecraft/protocol/legacy_v1_3.rs similarity index 100% rename from src/protocols/minecraft/protocol/legacy_v1_3.rs rename to crates/lib/src/protocols/minecraft/protocol/legacy_v1_3.rs diff --git a/src/protocols/minecraft/protocol/legacy_v1_5.rs b/crates/lib/src/protocols/minecraft/protocol/legacy_v1_5.rs similarity index 100% rename from src/protocols/minecraft/protocol/legacy_v1_5.rs rename to crates/lib/src/protocols/minecraft/protocol/legacy_v1_5.rs diff --git a/src/protocols/minecraft/protocol/legacy_v1_6.rs b/crates/lib/src/protocols/minecraft/protocol/legacy_v1_6.rs similarity index 100% rename from src/protocols/minecraft/protocol/legacy_v1_6.rs rename to crates/lib/src/protocols/minecraft/protocol/legacy_v1_6.rs diff --git a/src/protocols/minecraft/protocol/mod.rs b/crates/lib/src/protocols/minecraft/protocol/mod.rs similarity index 100% rename from src/protocols/minecraft/protocol/mod.rs rename to crates/lib/src/protocols/minecraft/protocol/mod.rs diff --git a/src/protocols/minecraft/types.rs b/crates/lib/src/protocols/minecraft/types.rs similarity index 100% rename from src/protocols/minecraft/types.rs rename to crates/lib/src/protocols/minecraft/types.rs diff --git a/src/protocols/mod.rs b/crates/lib/src/protocols/mod.rs similarity index 100% rename from src/protocols/mod.rs rename to crates/lib/src/protocols/mod.rs diff --git a/src/protocols/quake/client.rs b/crates/lib/src/protocols/quake/client.rs similarity index 100% rename from src/protocols/quake/client.rs rename to crates/lib/src/protocols/quake/client.rs diff --git a/src/protocols/quake/mod.rs b/crates/lib/src/protocols/quake/mod.rs similarity index 100% rename from src/protocols/quake/mod.rs rename to crates/lib/src/protocols/quake/mod.rs diff --git a/src/protocols/quake/one.rs b/crates/lib/src/protocols/quake/one.rs similarity index 100% rename from src/protocols/quake/one.rs rename to crates/lib/src/protocols/quake/one.rs diff --git a/src/protocols/quake/three.rs b/crates/lib/src/protocols/quake/three.rs similarity index 100% rename from src/protocols/quake/three.rs rename to crates/lib/src/protocols/quake/three.rs diff --git a/src/protocols/quake/two.rs b/crates/lib/src/protocols/quake/two.rs similarity index 100% rename from src/protocols/quake/two.rs rename to crates/lib/src/protocols/quake/two.rs diff --git a/src/protocols/quake/types.rs b/crates/lib/src/protocols/quake/types.rs similarity index 100% rename from src/protocols/quake/types.rs rename to crates/lib/src/protocols/quake/types.rs diff --git a/src/protocols/types.rs b/crates/lib/src/protocols/types.rs similarity index 100% rename from src/protocols/types.rs rename to crates/lib/src/protocols/types.rs diff --git a/src/protocols/valve/mod.rs b/crates/lib/src/protocols/valve/mod.rs similarity index 100% rename from src/protocols/valve/mod.rs rename to crates/lib/src/protocols/valve/mod.rs diff --git a/src/protocols/valve/protocol.rs b/crates/lib/src/protocols/valve/protocol.rs similarity index 100% rename from src/protocols/valve/protocol.rs rename to crates/lib/src/protocols/valve/protocol.rs diff --git a/src/protocols/valve/types.rs b/crates/lib/src/protocols/valve/types.rs similarity index 100% rename from src/protocols/valve/types.rs rename to crates/lib/src/protocols/valve/types.rs diff --git a/src/services/mod.rs b/crates/lib/src/services/mod.rs similarity index 100% rename from src/services/mod.rs rename to crates/lib/src/services/mod.rs diff --git a/src/services/valve_master_server/mod.rs b/crates/lib/src/services/valve_master_server/mod.rs similarity index 100% rename from src/services/valve_master_server/mod.rs rename to crates/lib/src/services/valve_master_server/mod.rs diff --git a/src/services/valve_master_server/service.rs b/crates/lib/src/services/valve_master_server/service.rs similarity index 100% rename from src/services/valve_master_server/service.rs rename to crates/lib/src/services/valve_master_server/service.rs diff --git a/src/services/valve_master_server/types.rs b/crates/lib/src/services/valve_master_server/types.rs similarity index 100% rename from src/services/valve_master_server/types.rs rename to crates/lib/src/services/valve_master_server/types.rs diff --git a/src/socket.rs b/crates/lib/src/socket.rs similarity index 100% rename from src/socket.rs rename to crates/lib/src/socket.rs diff --git a/src/utils.rs b/crates/lib/src/utils.rs similarity index 100% rename from src/utils.rs rename to crates/lib/src/utils.rs From 6084c56d4f8b09113abbc175a55638be0b3db8e2 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Mon, 16 Oct 2023 22:21:11 +0000 Subject: [PATCH 2/9] Add/Update badge --- .github/badges/node.svg | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/badges/node.svg b/.github/badges/node.svg index 18d8a03b..f2dafccb 100644 --- a/.github/badges/node.svg +++ b/.github/badges/node.svg @@ -1,20 +1,20 @@ - - Node game coverage: 12% + + Node game coverage: 0% - + - - + + \ No newline at end of file From 7d4649b6f5b3f7c7c459ca2d39147cff53abd53b Mon Sep 17 00:00:00 2001 From: Cain <75994858+cainthebest@users.noreply.github.com> Date: Tue, 17 Oct 2023 00:05:32 +0100 Subject: [PATCH 3/9] refactor: cli to work next to lib --- crates/cli/Cargo.toml | 12 ++---- crates/cli/src/error.rs | 4 +- crates/cli/src/key.rs | 93 ----------------------------------------- crates/cli/src/main.rs | 71 ++++++++----------------------- 4 files changed, 22 insertions(+), 158 deletions(-) delete mode 100644 crates/cli/src/key.rs diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index a93c1b50..b02867be 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -1,6 +1,8 @@ [package] name = "gamedig-cli" -authors = ["rust-GameDig contributors [https://github.com/gamedig/rust-gamedig/contributors]"] +authors = [ + "rust-GameDig contributors [https://github.com/gamedig/rust-gamedig/contributors]", +] description = "A command line interface for gamedig" license = "MIT" version = "0.4.1" @@ -11,12 +13,4 @@ edition = "2021" [dependencies] clap = { version = "4.1.11", features = ["derive"] } gamedig = { version = "*", path = "../lib" } -strum = "0.25.0" -strum_macros = "0.24.3" thiserror = "1.0.43" - -[profile.release] -opt-level = 3 -debug = false -rpath = true -lto = true \ No newline at end of file diff --git a/crates/cli/src/error.rs b/crates/cli/src/error.rs index 882de15e..c6f5d33a 100644 --- a/crates/cli/src/error.rs +++ b/crates/cli/src/error.rs @@ -11,6 +11,6 @@ pub enum Error { #[error("Gamedig Error: {0}")] Gamedig(#[from] gamedig::errors::GDError), - #[error("Strum Error: {0}")] - Strum(#[from] strum::ParseError), + #[error("Unknown Game: {0}")] + UnknownGame(String), } \ No newline at end of file diff --git a/crates/cli/src/key.rs b/crates/cli/src/key.rs deleted file mode 100644 index a1c19ba5..00000000 --- a/crates/cli/src/key.rs +++ /dev/null @@ -1,93 +0,0 @@ -use strum_macros::{Display, EnumString}; - -#[derive(EnumString, Display, Debug, Clone)] -pub enum Game { - #[strum(serialize = "aliens")] - AlienSwarm, - #[strum(serialize = "aoc")] - AgeOfChivalry, - #[strum(serialize = "arma2oa")] - ARMA2OperationArrowhead, - #[strum(serialize = "ase")] - ARKSurvivalEvolved, - #[strum(serialize = "asrd")] - AlienSwarmReactiveDrop, - #[strum(serialize = "avorion")] - Avorion, - #[strum(serialize = "bat1944")] - Battalion1944, - #[strum(serialize = "bb2")] - BrainBread2, - #[strum(serialize = "bf1942")] - Battlefield1942, - #[strum(serialize = "bm")] - BlackMesa, - #[strum(serialize = "bo")] - BallisticOverkill, - #[strum(serialize = "ccure")] - CodenameCURE, - #[strum(serialize = "cosu")] - ColonySurvival, - #[strum(serialize = "cs")] - CounterStrike, - #[strum(serialize = "cscz")] - CounterStrikeConditionZero, - #[strum(serialize = "csgo")] - CounterStrikeGlobalOffensive, - #[strum(serialize = "css")] - CounterStrikeSource, - #[strum(serialize = "dod")] - DayOfDefeat, - #[strum(serialize = "dods")] - DayOfDefeatSource, - #[strum(serialize = "doi")] - DayOfInfamy, - #[strum(serialize = "dst")] - DontStarveTogether, - #[strum(serialize = "gm")] - GarrysMod, - #[strum(serialize = "hl2dm")] - HalfLife2Deathmatch, - #[strum(serialize = "hldms")] - HalfLifeDeathmatchSource, - #[strum(serialize = "ins")] - Insurgency, - #[strum(serialize = "insmic")] - InsurgencyModernInfantryCombat, - #[strum(serialize = "inss")] - InsurgencySandstorm, - #[strum(serialize = "l4d")] - Left4Dead, - #[strum(serialize = "l4d2")] - Left4Dead2, - #[strum(serialize = "mc")] - Minecraft, - #[strum(serialize = "ohd")] - OperationHarshDoorstop, - #[strum(serialize = "onset")] - Onset, - #[strum(serialize = "pz")] - ProjectZomboid, - #[strum(serialize = "ror2")] - RiskOfRain2, - #[strum(serialize = "rust")] - Rust, - #[strum(serialize = "sc")] - SvenCoOp, - #[strum(serialize = "sdtd")] - SevenDaysToDie, - #[strum(serialize = "tf")] - TeamFortress, - #[strum(serialize = "tf2")] - TeamFortress2, - #[strum(serialize = "tfc")] - TeamFortressClassic, - #[strum(serialize = "ts")] - TheShip, - #[strum(serialize = "unturned")] - Unturned, - #[strum(serialize = "ut")] - UnrealTournament, - #[strum(serialize = "vr")] - VRising, -} \ No newline at end of file diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index 479ecfbf..934f0b26 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -1,73 +1,36 @@ -mod error; -mod key; - -use self::{error::Result, key::Game}; +use std::net::IpAddr; use clap::Parser; use gamedig::games::*; +mod error; + +use self::error::Result; + #[derive(Parser)] #[command(author, version, about)] struct Cli { #[arg(short, long)] - game: Game, + game: String, #[arg(short, long)] - ip: String, + ip: IpAddr, #[arg(short, long)] - port: u16, + port: Option, } #[rustfmt::skip] fn main() -> Result<()> { let args = Cli::parse(); - match args.game { - Game::AlienSwarm => Ok(println!("{:#?}", aliens::query(&args.ip, Some(args.port))?)), - Game::AgeOfChivalry => Ok(println!("{:#?}", aoc::query(&args.ip, Some(args.port))?)), - Game::ARMA2OperationArrowhead => Ok(println!("{:#?}", arma2oa::query(&args.ip, Some(args.port))?)), - Game::ARKSurvivalEvolved => Ok(println!("{:#?}", ase::query(&args.ip, Some(args.port))?)), - Game::AlienSwarmReactiveDrop => Ok(println!("{:#?}", asrd::query(&args.ip, Some(args.port))?)), - Game::Avorion => Ok(println!("{:#?}", avorion::query(&args.ip, Some(args.port))?)), - Game::Battalion1944 => Ok(println!("{:#?}", bat1944::query(&args.ip, Some(args.port))?)), - Game::BrainBread2 => Ok(println!("{:#?}", bb2::query(&args.ip, Some(args.port))?)), - Game::Battlefield1942 => Ok(println!("{:#?}", bf1942::query(&args.ip, Some(args.port))?)), - Game::BlackMesa => Ok(println!("{:#?}", bm::query(&args.ip, Some(args.port))?)), - Game::BallisticOverkill => Ok(println!("{:#?}", bo::query(&args.ip, Some(args.port))?)), - Game::CodenameCURE => Ok(println!("{:#?}", ccure::query(&args.ip, Some(args.port))?)), - Game::ColonySurvival => Ok(println!("{:#?}", cosu::query(&args.ip, Some(args.port))?)), - Game::CounterStrike => Ok(println!("{:#?}", cs::query(&args.ip, Some(args.port))?)), - Game::CounterStrikeConditionZero => Ok(println!("{:#?}", cscz::query(&args.ip, Some(args.port))?)), - Game::CounterStrikeGlobalOffensive => Ok(println!("{:#?}", csgo::query(&args.ip, Some(args.port))?)), - Game::CounterStrikeSource => Ok(println!("{:#?}", css::query(&args.ip, Some(args.port))?)), - Game::DayOfDefeat => Ok(println!("{:#?}", dod::query(&args.ip, Some(args.port))?)), - Game::DayOfDefeatSource => Ok(println!("{:#?}", dods::query(&args.ip, Some(args.port))?)), - Game::DayOfInfamy => Ok(println!("{:#?}", doi::query(&args.ip, Some(args.port))?)), - Game::DontStarveTogether => Ok(println!("{:#?}", dst::query(&args.ip, Some(args.port))?)), - Game::GarrysMod => Ok(println!("{:#?}", gm::query(&args.ip, Some(args.port))?)), - Game::HalfLife2Deathmatch => Ok(println!("{:#?}", hl2dm::query(&args.ip, Some(args.port))?)), - Game::HalfLifeDeathmatchSource => Ok(println!("{:#?}", hldms::query(&args.ip, Some(args.port))?)), - Game::Insurgency => Ok(println!("{:#?}", ins::query(&args.ip, Some(args.port))?)), - Game::InsurgencyModernInfantryCombat => Ok(println!("{:#?}", insmic::query(&args.ip, Some(args.port))?)), - Game::InsurgencySandstorm => Ok(println!("{:#?}", inss::query(&args.ip, Some(args.port))?)), - Game::Left4Dead => Ok(println!("{:#?}", l4d::query(&args.ip, Some(args.port))?)), - Game::Left4Dead2 => Ok(println!("{:#?}", l4d2::query(&args.ip, Some(args.port))?)), - Game::Minecraft => Ok(println!("{:#?}", mc::query(&args.ip, Some(args.port))?)), - Game::OperationHarshDoorstop => Ok(println!("{:#?}", ohd::query(&args.ip, Some(args.port))?)), - Game::Onset => Ok(println!("{:#?}", onset::query(&args.ip, Some(args.port))?)), - Game::ProjectZomboid => Ok(println!("{:#?}", pz::query(&args.ip, Some(args.port))?)), - Game::RiskOfRain2 => Ok(println!("{:#?}", ror2::query(&args.ip, Some(args.port))?)), - Game::Rust => Ok(println!("{:#?}", rust::query(&args.ip, Some(args.port))?)), - Game::SvenCoOp => Ok(println!("{:#?}", sc::query(&args.ip, Some(args.port))?)), - Game::SevenDaysToDie => Ok(println!("{:#?}", sdtd::query(&args.ip, Some(args.port))?)), - Game::TeamFortress => Ok(println!("{:#?}", tf::query(&args.ip, Some(args.port))?)), - Game::TeamFortress2 => Ok(println!("{:#?}", tf2::query(&args.ip, Some(args.port))?)), - Game::TeamFortressClassic => Ok(println!("{:#?}", tfc::query(&args.ip, Some(args.port))?)), - Game::TheShip => Ok(println!("{:#?}", ts::query(&args.ip, Some(args.port))?)), - Game::Unturned => Ok(println!("{:#?}", unturned::query(&args.ip, Some(args.port))?)), - Game::UnrealTournament => Ok(println!("{:#?}", ut::query(&args.ip, Some(args.port))?)), - Game::VRising => Ok(println!("{:#?}", vr::query(&args.ip, Some(args.port))?)), + let game = match GAMES.get(&args.game) { + Some(game) => game, + None => return Err(error::Error::UnknownGame(args.game)), + }; + + println!("{:#?}", query(game, &args.ip, args.port)?.as_json()); + + Ok(()) - } -} \ No newline at end of file +} From d34d61578446716bece33a08187e04d0aa8f5a6e Mon Sep 17 00:00:00 2001 From: Douile Date: Tue, 17 Oct 2023 13:05:02 +0100 Subject: [PATCH 4/9] [CI] Update CI to work with workspaces --- .github/labeler.yml | 7 +++++-- .github/workflows/ci.yml | 16 ++++++++-------- .github/workflows/node-badge.yml | 2 +- .pre-commit-config.yaml | 12 ++++++------ Cargo.toml | 4 +++- 5 files changed, 23 insertions(+), 18 deletions(-) diff --git a/.github/labeler.yml b/.github/labeler.yml index 31043c59..76326b39 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -5,10 +5,13 @@ ci: - .pre-commit-config.yaml protocol: - - src/protocols/** + - crates/lib/src/protocols/** game: - - src/games/** + - crates/lib/src/games/** + +cli: + - crates/cli/** crate: - Cargo.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 85ce36d3..7e9192e4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,9 +31,9 @@ jobs: shared-key: "cargo-deps" cache-targets: false - name: Run Build - run: cargo build --verbose --bins --lib --examples --all-features + run: cargo check --verbose --workspace --bins --lib --examples --all-features - name: Run Tests - run: cargo test --verbose --bins --lib --examples --all-features + run: cargo test --verbose --workspace --bins --lib --examples --all-features build: runs-on: ubuntu-latest needs: [ "build_first" ] @@ -61,9 +61,9 @@ jobs: shared-key: "cargo-deps" cache-targets: false - name: Run Build - run: cargo build --verbose --bins --lib ${{ matrix.build_type }} + run: cargo check --workspace --verbose --bins --lib ${{ matrix.build_type }} build_msrv: - name: "Build using MSRV" + name: "Build using MSRV (lib only)" runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -74,7 +74,7 @@ jobs: toolchain: 1.65.0 override: true - name: Run MSRV - run: cargo build + run: cargo check -p gamedig formatting: name: "Check code formatting" runs-on: ubuntu-latest @@ -105,10 +105,10 @@ jobs: uses: actions-rs/clippy-check@v1 with: token: ${{ secrets.GITHUB_TOKEN }} - args: --bins --lib --examples --all-features + args: --workspace --bins --lib --examples --all-features if: ${{ !env.ACT }} # skip during local actions testing - name: Run clippy (local) - run: cargo clippy --verbose --bins --lib --examples --all-features + run: cargo clippy --workspace --verbose --bins --lib --examples --all-features if: ${{ env.ACT }} # only run during local actions testing doc: name: "Check rustdoc" @@ -121,6 +121,6 @@ jobs: shared-key: "cargo-deps" cache-targets: false - name: "Run cargo doc" - run: cargo doc + run: cargo doc --workspace env: RUSTDOCFLAGS: "-D warnings" diff --git a/.github/workflows/node-badge.yml b/.github/workflows/node-badge.yml index b6865eea..b0b33afc 100644 --- a/.github/workflows/node-badge.yml +++ b/.github/workflows/node-badge.yml @@ -39,7 +39,7 @@ jobs: # Calculate how many of those games we have definitions for rust_games_count=0 for game in $node_games; do - if grep "\"$game\" *=>" ./src/games/definitions.rs; then + if grep "\"$game\" *=>" ./crates/lib/src/games/definitions.rs; then rust_games_count=$(( rust_games_count + 1 )) fi done diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7449aee9..6e7adc33 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,25 +8,25 @@ repos: language: system files: '[.]rs$' pass_filenames: false - entry: rustup run --install nightly-2023-07-09 cargo-clippy -- -- -D warnings + entry: rustup run --install nightly-2023-07-09 cargo-clippy -- --workspace --all-features -- -D warnings - id: build-no-features name: Check crate build with no features language: system files: '[.]rs$' pass_filenames: false - entry: cargo build --no-default-features + entry: cargo check --workspace --no-default-features - id: build-all-features name: Check crate builds with all features language: system files: '[.]rs$' pass_filenames: false - entry: cargo build --all-features --lib --bins --examples + entry: cargo check --workspace --all-features --lib --bins --examples - id: test name: Check tests pass language: system files: '[.]rs$' pass_filenames: false - entry: cargo test --bins --lib --examples --all-features + entry: cargo test --workspace --bins --lib --examples --all-features - id: format name: Check rustfmt language: system @@ -34,11 +34,11 @@ repos: pass_filenames: false entry: rustup run --install nightly-2023-07-09 cargo-fmt --check - id: msrv - name: Check MSRV compiles + name: Check MSRV compiles (lib only) language: system files: '[.]rs$' pass_filenames: false - entry: rustup run --install 1.65 cargo build + entry: rustup run --install 1.65 cargo check -p gamedig - id: docs name: Check rustdoc compiles language: system diff --git a/Cargo.toml b/Cargo.toml index 8d744031..a729bd25 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,4 +3,6 @@ name = "gamedig-workspace" members = [ "crates/cli", "crates/lib", -] \ No newline at end of file +] +# Edition 2021, uses resolver = 2 +resolver = "2" From 9644163c8c348d4ce79d035cda4e112d08929f51 Mon Sep 17 00:00:00 2001 From: Douile Date: Tue, 17 Oct 2023 13:07:52 +0100 Subject: [PATCH 5/9] [fmt] Run rustfmt on crates/cli/src/error.rs --- crates/cli/src/error.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/cli/src/error.rs b/crates/cli/src/error.rs index c6f5d33a..49b68136 100644 --- a/crates/cli/src/error.rs +++ b/crates/cli/src/error.rs @@ -13,4 +13,4 @@ pub enum Error { #[error("Unknown Game: {0}")] UnknownGame(String), -} \ No newline at end of file +} From 6b92e883efb875bcbac1721ef5201de78008df7c Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Tue, 17 Oct 2023 23:31:19 +0000 Subject: [PATCH 6/9] Add/Update badge --- .github/badges/node.svg | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/badges/node.svg b/.github/badges/node.svg index f2dafccb..18d8a03b 100644 --- a/.github/badges/node.svg +++ b/.github/badges/node.svg @@ -1,20 +1,20 @@ - - Node game coverage: 0% + + Node game coverage: 12% - + - - + + \ No newline at end of file From 92ad618723ec28ef0c910a31db22dcff0ab328e8 Mon Sep 17 00:00:00 2001 From: Cain <75994858+cainthebest@users.noreply.github.com> Date: Wed, 8 Nov 2023 20:22:04 +0000 Subject: [PATCH 7/9] chore: remove un-needed fmt skip --- crates/cli/src/main.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index 934f0b26..b21b0ae0 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -20,7 +20,6 @@ struct Cli { port: Option, } -#[rustfmt::skip] fn main() -> Result<()> { let args = Cli::parse(); @@ -29,8 +28,7 @@ fn main() -> Result<()> { None => return Err(error::Error::UnknownGame(args.game)), }; - println!("{:#?}", query(game, &args.ip, args.port)?.as_json()); + println!("{:#?}", query(game, &args.ip, args.port)?.as_json()); - Ok(()) - + Ok(()) } From 338df9144c79008904dbaa4403f454a62a078bb1 Mon Sep 17 00:00:00 2001 From: Cain <75994858+cainthebest@users.noreply.github.com> Date: Wed, 8 Nov 2023 20:44:31 +0000 Subject: [PATCH 8/9] chore: update cargo.toml --- crates/lib/Cargo.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/lib/Cargo.toml b/crates/lib/Cargo.toml index 4949cc1e..f3199b36 100644 --- a/crates/lib/Cargo.toml +++ b/crates/lib/Cargo.toml @@ -28,7 +28,8 @@ byteorder = "1.5" bzip2-rs = "0.1" crc32fast = "1.3" serde_json = "1.0" +encoding_rs = "0.8" serde = { version = "1.0", optional = true } -phf = { version = "0.11", optional = true, features = ["macros"] } +phf = { version = "0.11", optional = true, features = ["macros"] } \ No newline at end of file From a11ca7f9aaf43efc0414ece6f112477cdb2712cc Mon Sep 17 00:00:00 2001 From: Cain <75994858+cainthebest@users.noreply.github.com> Date: Wed, 8 Nov 2023 21:11:25 +0000 Subject: [PATCH 9/9] chore: add release opts --- Cargo.toml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a729bd25..4dd9c760 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,15 @@ [workspace] name = "gamedig-workspace" -members = [ - "crates/cli", - "crates/lib", -] +members = ["crates/cli", "crates/lib"] + # Edition 2021, uses resolver = 2 resolver = "2" + +[profile.release] +opt-level = 3 +debug = false +rpath = true +lto = true + +[profile.release.package."*"] +opt-level = 3