Skip to content

Commit

Permalink
chore: bump archspec-json (#11)
Browse files Browse the repository at this point in the history
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 <COMMAND>

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
```
  • Loading branch information
baszalmstra authored May 27, 2024
1 parent a88dffa commit ff45a9b
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/rust-compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[workspace]
members = [ "bin"]
default-members = [ "bin"]

[package]
name = "archspec"
version = "0.1.3"
Expand All @@ -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]
Expand All @@ -23,4 +27,4 @@ libc = "0.2"
sysctl = "0.5"

[dev-dependencies]
rstest = "0.18.2"
rstest = "0.19"
9 changes: 9 additions & 0 deletions bin/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"] }
29 changes: 29 additions & 0 deletions bin/src/bin/archspec.rs
Original file line number Diff line number Diff line change
@@ -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"),
}
}
2 changes: 1 addition & 1 deletion json

0 comments on commit ff45a9b

Please sign in to comment.