From ff45a9b4a2bc484d5c27f650f4fe9940fd302731 Mon Sep 17 00:00:00 2001 From: Bas Zalmstra Date: Mon, 27 May 2024 15:06:58 +0200 Subject: [PATCH] chore: bump archspec-json (#11) Bump [archspec-json](https://github.com/archspec/archspec-json) and adds a small binary to works similarly to the archspec python implementation. ``` archspec command line interface Usage: archspec.exe Commands: cpu archspec command line interface for CPU help Print this message or the help of the given subcommand(s) Options: -h, --help Print help -V, --version Print version ``` --- .github/workflows/rust-compile.yml | 4 ++-- Cargo.toml | 8 ++++++-- bin/Cargo.toml | 9 +++++++++ bin/src/bin/archspec.rs | 29 +++++++++++++++++++++++++++++ json | 2 +- 5 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 bin/Cargo.toml create mode 100644 bin/src/bin/archspec.rs diff --git a/.github/workflows/rust-compile.yml b/.github/workflows/rust-compile.yml index e0f485d..a324a11 100644 --- a/.github/workflows/rust-compile.yml +++ b/.github/workflows/rust-compile.yml @@ -72,7 +72,7 @@ jobs: - uses: Swatinem/rust-cache@v2 - name: Run clippy - run: cargo clippy + run: cargo clippy --all - name: "Install cargo nextest" uses: taiki-e/install-action@v2 @@ -81,4 +81,4 @@ jobs: - name: "Cargo nextest" run: | - cargo nextest run --no-capture --status-level skip --no-fail-fast --final-status-level slow + cargo nextest run --no-capture --status-level skip --no-fail-fast --final-status-level slow --all diff --git a/Cargo.toml b/Cargo.toml index 440a3f7..a036a4a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,7 @@ +[workspace] +members = [ "bin"] +default-members = [ "bin"] + [package] name = "archspec" version = "0.1.3" @@ -13,7 +17,7 @@ repository = "https://github.com/prefix-dev/archspec-rs" [dependencies] serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -itertools = "0.12" +itertools = "0.13" cfg-if = "1" [target.'cfg(not(target_os = "windows"))'.dependencies] @@ -23,4 +27,4 @@ libc = "0.2" sysctl = "0.5" [dev-dependencies] -rstest = "0.18.2" +rstest = "0.19" diff --git a/bin/Cargo.toml b/bin/Cargo.toml new file mode 100644 index 0000000..2d01466 --- /dev/null +++ b/bin/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "archspec-bin" +version = "0.1.0" +edition = "2021" +publish = false + +[dependencies] +archspec = { path = ".." } +clap = { version = "4.5.4", features = ["derive"] } diff --git a/bin/src/bin/archspec.rs b/bin/src/bin/archspec.rs new file mode 100644 index 0000000..a86f9a1 --- /dev/null +++ b/bin/src/bin/archspec.rs @@ -0,0 +1,29 @@ +use clap::{Parser, Subcommand}; + +/// Simple program to greet a person +#[derive(Parser, Debug)] +#[command(version, about = "archspec command line interface", long_about = None)] +struct Args { + #[command(subcommand)] + command: Command, +} + +#[derive(Subcommand, Clone, Debug)] +enum Command { + /// archspec command line interface for CPU + Cpu, +} + +fn main() { + let args = Args::parse(); + match args.command { + Command::Cpu => detect_cpu(), + } +} + +fn detect_cpu() { + match archspec::cpu::host() { + Ok(arch) => println!("{}", arch.name()), + Err(_err) => eprintln!("Error: unsupported micro architecture"), + } +} diff --git a/json b/json index e240b17..9eb03ac 160000 --- a/json +++ b/json @@ -1 +1 @@ -Subproject commit e240b17000d3ffeea0d3be9f130d9da0362e4e94 +Subproject commit 9eb03acd73b70e136c91fb4b88a18d18713048a7