Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .cargo/config.toml

This file was deleted.

14 changes: 3 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ license = "MIT"
keywords = ["hardware", "sensors", "hwmon", "system-info", "monitoring"]
categories = ["command-line-utilities", "hardware-support"]
repository = "https://github.com/level1techs/siomon"
build = "build.rs"
exclude = ["packaging/", "assets/", "kmod/", ".github/", "CONTRIBUTING.md", "PACKAGING.md", "cliff.toml"]

[[bin]]
Expand All @@ -28,12 +29,16 @@ csv = ["dep:csv"]
raw-cpuid = "11"

[workspace]
members = [".", "xtask"]
members = ["."]

[workspace.dependencies]
clap = { version = "4", features = ["derive", "env", "string"] }
clap_complete = "4"

[build-dependencies]
clap.workspace = true
clap_complete.workspace = true


[dependencies]
# Serialization
Expand Down
17 changes: 17 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use clap::CommandFactory;
use clap_complete::aot::{Shell, generate_to};

include!("src/opts.rs");

fn main() -> std::io::Result<()> {
let outdir = std::env::var("CARGO_TARGET_DIR").unwrap_or("./target".to_string());
let mut cmd = Cli::command();

std::fs::create_dir_all(&outdir)?;
generate_to(Shell::Bash, &mut cmd, "sio", &outdir)?;
generate_to(Shell::Zsh, &mut cmd, "sio", &outdir)?;
generate_to(Shell::Fish, &mut cmd, "sio", &outdir)?;

println!("cargo:warning=shell completions generated in {outdir}/");
Ok(())
}
14 changes: 4 additions & 10 deletions packaging/aur/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,10 @@ package() {
export RUSTUP_TOOLCHAIN=stable
cargo install --no-track --frozen --all-features --root "$pkgdir/usr/" --path .

# Shell completions — xtask reuses the build cache from cargo install above
install -dm755 "$pkgdir/usr/share/bash-completion/completions"
install -dm755 "$pkgdir/usr/share/zsh/site-functions"
install -dm755 "$pkgdir/usr/share/fish/vendor_completions.d"
cargo run --frozen --package xtask -- shell-completion bash \
> "$pkgdir/usr/share/bash-completion/completions/sio"
cargo run --frozen --package xtask -- shell-completion zsh \
> "$pkgdir/usr/share/zsh/site-functions/_sio"
cargo run --frozen --package xtask -- shell-completion fish \
> "$pkgdir/usr/share/fish/vendor_completions.d/sio.fish"
# Shell completions (pre-generated by build.rs)
install -Dm644 target/sio.bash "$pkgdir/usr/share/bash-completion/completions/sio"
install -Dm644 target/_sio "$pkgdir/usr/share/zsh/site-functions/_sio"
install -Dm644 target/sio.fish "$pkgdir/usr/share/fish/vendor_completions.d/sio.fish"

install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

Expand Down
6 changes: 1 addition & 5 deletions packaging/launchpad/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,13 @@ override_dh_auto_configure:

override_dh_auto_build:
cargo build --frozen --release --all-features
cargo run --frozen --package xtask -- shell-completion bash > target/sio.bash
cargo run --frozen --package xtask -- shell-completion zsh > target/sio.zsh
cargo run --frozen --package xtask -- shell-completion fish > target/sio.fish

# Tests require hardware/sysfs interfaces not available in Launchpad build chroot
override_dh_auto_test:

override_dh_auto_install:
install -D -m 0755 target/release/sio debian/siomon/usr/bin/sio
install -D -m 0644 target/sio.bash debian/siomon/usr/share/bash-completion/completions/sio
install -D -m 0644 target/sio.zsh debian/siomon/usr/share/zsh/vendor-completions/_sio
install -D -m 0644 target/_sio debian/siomon/usr/share/zsh/vendor-completions/_sio
install -D -m 0644 target/sio.fish debian/siomon/usr/share/fish/vendor_completions.d/sio.fish

override_dh_auto_clean:
Expand Down
93 changes: 1 addition & 92 deletions src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,99 +1,8 @@
//! Command-line argument parsing and config-file application.

use clap::{Parser, Subcommand, ValueEnum};

use crate::config::SiomonConfig;

#[derive(Parser, Debug)]
#[command(
name = "sio",
about = "Linux hardware information and sensor monitoring",
version,
author
)]
pub struct Cli {
#[command(subcommand)]
pub command: Option<Commands>,

/// Output format
#[arg(short = 'f', long, value_enum, default_value_t = OutputFormat::Text, global = true)]
pub format: OutputFormat,

/// Run in TUI (interactive) sensor monitor mode (press '/' to cross-filter)
#[arg(short = 'm', long = "monitor", global = true)]
pub tui: bool,

/// Sensor polling interval in milliseconds
#[arg(long, default_value_t = 1000, global = true)]
pub interval: u64,

/// Disable NVIDIA GPU detection
#[arg(long, global = true)]
pub no_nvidia: bool,

/// Enable direct I/O port and I2C sensor reading (requires root)
#[arg(long, global = true)]
pub direct_io: bool,

/// Show empty/unavailable fields
#[arg(long, global = true)]
pub show_empty: bool,

/// Log sensor data to CSV file while monitoring
#[arg(long, global = true)]
pub log: Option<std::path::PathBuf>,

/// Sensor alert rules (e.g., "hwmon/nct6798/temp1 > 80 @30s")
#[arg(long = "alert", value_name = "RULE", global = true)]
pub alerts: Vec<String>,

/// Color mode
#[arg(long, value_enum, default_value_t = ColorMode::Auto, global = true)]
pub color: ColorMode,
}

#[derive(Subcommand, Debug)]
pub enum Commands {
/// CPU information
Cpu,
/// GPU information
Gpu,
/// Memory information
Memory,
/// Storage device information
Storage,
/// Network adapter information
Network,
/// PCI device list
Pci,
/// USB device list
Usb,
/// Audio device information
Audio,
/// Battery information
Battery,
/// Motherboard and BIOS information
Board,
/// PCIe link details (speed, width, ASPM)
Pcie,
/// Sensor readings (one-shot snapshot)
Sensors,
}

#[derive(ValueEnum, Clone, Debug, PartialEq, Eq)]
pub enum OutputFormat {
Text,
Json,
Xml,
Html,
}

#[derive(ValueEnum, Clone, Debug)]
pub enum ColorMode {
Auto,
Always,
Never,
}
pub use crate::opts::*;

impl Cli {
/// Apply config file values for any CLI argument that wasn't explicitly set.
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/// Command-line argument parsing and config application (clap).
pub mod cli;
/// Clap argument definitions (shared with build.rs via include!).
mod opts;
/// One-shot hardware information collectors (`Collector` trait).
pub mod collectors;
/// Configuration file loading (`~/.config/siomon/config.toml`).
Expand Down
92 changes: 92 additions & 0 deletions src/opts.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
use clap::{Parser, Subcommand, ValueEnum};

#[derive(Parser, Debug)]
#[command(
name = "sio",
about = "Linux hardware information and sensor monitoring",
version,
author
)]
pub struct Cli {
#[command(subcommand)]
pub command: Option<Commands>,

/// Output format
#[arg(short = 'f', long, value_enum, default_value_t = OutputFormat::Text, global = true)]
pub format: OutputFormat,

/// Run in TUI (interactive) sensor monitor mode (press '/' to cross-filter)
#[arg(short = 'm', long = "monitor", global = true)]
pub tui: bool,

/// Sensor polling interval in milliseconds
#[arg(long, default_value_t = 1000, global = true)]
pub interval: u64,

/// Disable NVIDIA GPU detection
#[arg(long, global = true)]
pub no_nvidia: bool,

/// Enable direct I/O port and I2C sensor reading (requires root)
#[arg(long, global = true)]
pub direct_io: bool,

/// Show empty/unavailable fields
#[arg(long, global = true)]
pub show_empty: bool,

/// Log sensor data to CSV file while monitoring
#[arg(long, global = true)]
pub log: Option<std::path::PathBuf>,

/// Sensor alert rules (e.g., "hwmon/nct6798/temp1 > 80 @30s")
#[arg(long = "alert", value_name = "RULE", global = true)]
pub alerts: Vec<String>,

/// Color mode
#[arg(long, value_enum, default_value_t = ColorMode::Auto, global = true)]
pub color: ColorMode,
}

#[derive(Subcommand, Debug)]
pub enum Commands {
/// CPU information
Cpu,
/// GPU information
Gpu,
/// Memory information
Memory,
/// Storage device information
Storage,
/// Network adapter information
Network,
/// PCI device list
Pci,
/// USB device list
Usb,
/// Audio device information
Audio,
/// Battery information
Battery,
/// Motherboard and BIOS information
Board,
/// PCIe link details (speed, width, ASPM)
Pcie,
/// Sensor readings (one-shot snapshot)
Sensors,
}

#[derive(ValueEnum, Clone, Debug, PartialEq, Eq)]
pub enum OutputFormat {
Text,
Json,
Xml,
Html,
}

#[derive(ValueEnum, Clone, Debug)]
pub enum ColorMode {
Auto,
Always,
Never,
}
9 changes: 0 additions & 9 deletions xtask/Cargo.toml

This file was deleted.

35 changes: 0 additions & 35 deletions xtask/src/main.rs

This file was deleted.