diff --git a/Cargo.lock b/Cargo.lock index 4080b95b..bc926642 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -519,6 +519,7 @@ dependencies = [ "uu_free", "uu_pmap", "uu_pwdx", + "uu_slabtop", "uu_w", "uu_watch", "uucore", @@ -856,6 +857,16 @@ dependencies = [ "uucore", ] +[[package]] +name = "uu_slabtop" +version = "0.0.1" +dependencies = [ + "bytesize", + "clap", + "sysinfo", + "uucore", +] + [[package]] name = "uu_w" version = "0.0.1" diff --git a/Cargo.toml b/Cargo.toml index 069d1327..17e40c43 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,13 +25,7 @@ build = "build.rs" default = ["feat_common_core"] uudoc = [] -feat_common_core = [ - "pwdx", - "free", - "w", - "watch", - "pmap", -] +feat_common_core = ["pwdx", "free", "w", "watch", "pmap"] [workspace.dependencies] uucore = "0.0.25" @@ -68,6 +62,7 @@ free = { optional = true, version = "0.0.1", package = "uu_free", path = "src/uu w = { optional = true, version = "0.0.1", package = "uu_w", path = "src/uu/w" } watch = { optional = true, version = "0.0.1", package = "uu_watch", path = "src/uu/watch" } pmap = { optional = true, version = "0.0.1", package = "uu_pmap", path = "src/uu/pmap" } +slabtop = { optional = true, version = "0.0.1", package = "uu_slabtop", path = "src/uu/slabtop" } [dev-dependencies] pretty_assertions = "1" diff --git a/src/uu/slabtop/Cargo.toml b/src/uu/slabtop/Cargo.toml new file mode 100644 index 00000000..df30e9c4 --- /dev/null +++ b/src/uu/slabtop/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "uu_slabtop" +version = "0.0.1" +edition = "2021" +authors = ["uutils developers"] +license = "MIT" +description = "slabtop ~ (uutils) Display kernel slab cache information in real time" + +homepage = "https://github.com/uutils/procps" +repository = "https://github.com/uutils/procps/tree/main/src/uu/slabtop" +keywords = ["acl", "uutils", "cross-platform", "cli", "utility"] +categories = ["command-line-utilities"] + + +[dependencies] +uucore = { workspace = true } +clap = { workspace = true } +bytesize = { workspace = true } + +sysinfo = { workspace = true } + +[lib] +path = "src/slabtop.rs" + +[[bin]] +name = "slabtop" +path = "src/main.rs" diff --git a/src/uu/slabtop/slabtop.md b/src/uu/slabtop/slabtop.md new file mode 100644 index 00000000..d1b3cf66 --- /dev/null +++ b/src/uu/slabtop/slabtop.md @@ -0,0 +1,7 @@ +# slabtop + +``` +slabtop [options] +``` + +Display kernel slab cache information in real time diff --git a/src/uu/slabtop/src/main.rs b/src/uu/slabtop/src/main.rs new file mode 100644 index 00000000..69ad1c14 --- /dev/null +++ b/src/uu/slabtop/src/main.rs @@ -0,0 +1 @@ +uucore::bin!(uu_slabtop); diff --git a/src/uu/slabtop/src/slabtop.rs b/src/uu/slabtop/src/slabtop.rs new file mode 100644 index 00000000..d9114cd9 --- /dev/null +++ b/src/uu/slabtop/src/slabtop.rs @@ -0,0 +1,32 @@ +// This file is part of the uutils procps package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. + +use clap::{arg, crate_version, ArgAction, Command}; +use uucore::{error::UResult, format_usage, help_about, help_usage}; + +const ABOUT: &str = help_about!("slabtop.md"); +const USAGE: &str = help_usage!("slabtop.md"); + +#[uucore::main] +pub fn uumain(args: impl uucore::Args) -> UResult<()> { + let _matches = uu_app().try_get_matches_from(args)?; + + Ok(()) +} + +pub fn uu_app() -> Command { + Command::new(uucore::util_name()) + .version(crate_version!()) + .about(ABOUT) + .override_usage(format_usage(USAGE)) + .infer_long_args(true) + .disable_help_flag(true) + .args([ + arg!(-d --delay "delay updates"), + arg!(-o --once "only display once, then exit"), + arg!(-s --sort "specify sort criteria by character (see below)"), + arg!(-h --help "display this help and exit").action(ArgAction::Help), + ]) +}