From 3bcf9385f2e6c973e024ea6a8e65d5d1cc13f7b7 Mon Sep 17 00:00:00 2001 From: Cain <75994858+cainthebest@users.noreply.github.com> Date: Tue, 26 Nov 2024 02:05:36 +0000 Subject: [PATCH] refactor(cli): improve how we serve the bin to users --- Cargo.toml | 7 +++++++ README.md | 3 ++- crates/cli/Cargo.toml | 11 +++++------ crates/cli/LICENSE.md | 21 +++++++++++++++++++++ crates/cli/README.md | 26 ++++++++++++++++---------- crates/cli/src/main.rs | 2 +- 6 files changed, 52 insertions(+), 18 deletions(-) create mode 100644 crates/cli/LICENSE.md diff --git a/Cargo.toml b/Cargo.toml index 739a816..0fe5ede 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,3 +13,10 @@ codegen-units = 1 [profile.release.package."*"] opt-level = 3 + +# When building locally, use the local version of the library +# Comment this out when you want to resolve the library from crates.io +# This is only for crates that use gamedig as a dependency +# https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html +[patch.crates-io] +gamedig = { path = "./crates/lib" } \ No newline at end of file diff --git a/README.md b/README.md index 8fa5734..512fb58 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,8 @@ Want to see more examples? Checkout the [examples](crates/lib/examples) folder. ## Command Line Interface -The library also has an official CLI: [GameDig-CLI](https://crates.io/crates/gamedig-cli). +The library also has an [official CLI](https://crates.io/crates/gamedig_cli) that you can use but it has +MSRV of `1.74.1`. ## Documentation diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 395aaf5..e1069fb 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "gamedig-cli" +name = "gamedig_cli" authors = [ "rust-GameDig contributors [https://github.com/gamedig/rust-gamedig/contributors]", ] @@ -7,14 +7,13 @@ description = "A command line interface for gamedig" license = "MIT" version = "0.1.1" edition = "2021" -default-run = "gamedig-cli" +default-run = "gamedig_cli" homepage = "https://gamedig.github.io/" -documentation = "https://docs.rs/gamedig-cli/latest/gamedig-cli/" repository = "https://github.com/gamedig/rust-gamedig" readme = "README.md" keywords = ["server", "query", "game", "check", "status"] -rust-version = "1.65.0" -categories = ["parsing", "command-line-interface"] +rust-version = "1.74.1" +categories = ["command-line-interface"] [features] default = ["json", "bson", "xml", "browser"] @@ -34,7 +33,7 @@ browser = ["dep:webbrowser"] # Core Dependencies thiserror = "2.0.0" clap = { version = "4.5.4", default-features = false, features = ["derive"] } -gamedig = { version = "*", path = "../lib", default-features = false, features = [ +gamedig = { version = "0.5", default-features = false, features = [ "clap", "games", "game_defs", diff --git a/crates/cli/LICENSE.md b/crates/cli/LICENSE.md new file mode 100644 index 0000000..212e039 --- /dev/null +++ b/crates/cli/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 - 2024 GameDig Organization & Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/crates/cli/README.md b/crates/cli/README.md index c1e1794..1c5b272 100644 --- a/crates/cli/README.md +++ b/crates/cli/README.md @@ -1,20 +1,26 @@ # rust-GameDig CLI -The official [rust-GameDig](https://crates.io/crates/gamedig) Command Line Interface. +The official [rust-GameDig](https://crates.io/crates/gamedig_cli) Command Line Interface. [![CI](https://github.com/gamedig/rust-gamedig/actions/workflows/ci.yml/badge.svg)](https://github.com/gamedig/rust-gamedig/actions) [![License:MIT](https://img.shields.io/github/license/gamedig/rust-gamedig?color=blue)](https://github.com/gamedig/rust-gamedig/blob/main/LICENSE.md) [![node coverage](https://raw.githubusercontent.com/gamedig/rust-gamedig/main/.github/badges/node.svg)](https://github.com/gamedig/node-gamedig) -## Community +## Installation -Checkout the GameDig Community Discord Server [here](https://discord.gg/NVCMn3tnxH). -Note that it isn't be a replacement for GitHub issues, if you have found a problem -within the library or want to request a feature, it's better to do so here rather than -on Discord. +You can install the CLI via `cargo`: + +```sh +cargo install gamedig_cli +``` + +or + +```sh +cargo install gamedig_cli --git https://github.com/gamedig/rust-gamedig.git +``` ## Usage -Just by running `gamedig-cli` prints the usage. -**Note**: Passing `--help` (or `-h`) shows the usage. +Running `gamedig_cli` without any arguments will display the usage information. You can also use the `--help` (or `-h`) flag to see detailed usage instructions. Here's also a quick rundown of a simple query with the `json-pretty` format: @@ -26,8 +32,8 @@ can also be optional if the server is running the default ports) then query on i [Team Fortress 2](https://store.steampowered.com/app/440/Team_Fortress_2/) query example: -``` -gamedig-cli query -g teamfortress2 -i 127.0.0.1 -f json-pretty +```sh +gamedig_cli query -g teamfortress2 -i 127.0.0.1 -f json-pretty ``` What we are doing here: diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index f20be84..cb4354d 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -479,7 +479,7 @@ fn main() -> Result<()> { Action::License => { // Bake the license into the binary // so we don't have to ship it separately - println!("{}", include_str!("../../../LICENSE.md")); + println!("{}", include_str!("../LICENSE.md")); } }