-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: merge gamedig-cli partially & monorepo conversion
Related issue: #125
- Loading branch information
Showing
71 changed files
with
133 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,15 @@ | ||
[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"] | ||
[workspace] | ||
name = "gamedig-workspace" | ||
members = ["crates/cli", "crates/lib"] | ||
|
||
[features] | ||
default = ["games", "services", "game_defs"] | ||
games = [] | ||
services = [] | ||
game_defs = ["dep:phf", "games"] | ||
serde = ["dep:serde", "serde/derive"] | ||
# Edition 2021, uses resolver = 2 | ||
resolver = "2" | ||
|
||
[dependencies] | ||
byteorder = "1.5" | ||
bzip2-rs = "0.1" | ||
crc32fast = "1.3" | ||
serde_json = "1.0" | ||
encoding_rs = "0.8" | ||
[profile.release] | ||
opt-level = 3 | ||
debug = false | ||
rpath = true | ||
lto = true | ||
|
||
serde = { version = "1.0", optional = true } | ||
|
||
phf = { version = "0.11", optional = true, features = ["macros"] } | ||
[profile.release.package."*"] | ||
opt-level = 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[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" } | ||
thiserror = "1.0.43" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
pub type Result<T> = std::result::Result<T, Error>; | ||
|
||
#[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("Unknown Game: {0}")] | ||
UnknownGame(String), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
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: String, | ||
|
||
#[arg(short, long)] | ||
ip: IpAddr, | ||
|
||
#[arg(short, long)] | ||
port: Option<u16>, | ||
} | ||
|
||
fn main() -> Result<()> { | ||
let args = Cli::parse(); | ||
|
||
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(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
[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" | ||
encoding_rs = "0.8" | ||
|
||
serde = { version = "1.0", optional = true } | ||
|
||
phf = { version = "0.11", optional = true, features = ["macros"] } |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.