1
0
mirror of https://github.com/orhun/kmon synced 2024-07-08 20:06:03 +00:00

Merge pull request #8 from tpiekarski/feature/sorting-arg-used-by

Creating new sorting argument for most-used modules, resolves #7
This commit is contained in:
orhun 2020-04-09 16:07:53 +03:00 committed by GitHub
commit 9c53b17353
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 5 deletions

2
Cargo.lock generated
View File

@ -182,7 +182,7 @@ dependencies = [
[[package]]
name = "kmon"
version = "1.0.1"
version = "1.1.0"
dependencies = [
"bytesize 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -1,6 +1,6 @@
[package]
name = "kmon"
version = "1.0.1"
version = "1.1.0"
description = "Linux kernel manager and activity monitor"
authors = ["orhun <orhunparmaksiz@gmail.com>"]
license = "GPL-3.0"

View File

@ -234,8 +234,9 @@ sort Sort kernel modules
kmon sort [FLAGS]
FLAGS:
-n, --name Sort modules by their names
-s, --size Sort modules by their sizes
-n, --name Sort modules by their names
-s, --size Sort modules by their sizes
-d, --dependent Sort modules by their dependent modules
```
## Key Bindings
@ -370,11 +371,12 @@ Use `ctrl-c/ctrl-v` for copying and pasting while in input mode.
### Sorting/reversing the kernel modules
`sort` subcommand can be used for sorting the kernel modules by their names or sizes.
`sort` subcommand can be used for sorting the kernel modules by their names, sizes or dependent modules.
```
kmon sort --name
kmon sort --size
kmon sort --dependent
```
Also the `-r, --reverse` flag is used for reversing the kernel module list.

View File

@ -11,6 +11,7 @@ enum SortType {
None,
Size,
Name,
Dependent,
}
/* Listing properties of module list */
@ -31,6 +32,8 @@ impl ListArgs {
if let Some(matches) = args.subcommand_matches("sort") {
if matches.is_present("size") {
sort_type = SortType::Size;
} else if matches.is_present("dependent") {
sort_type = SortType::Dependent;
} else {
sort_type = SortType::Name;
}
@ -87,6 +90,7 @@ impl KernelModules<'_> {
match self.args.sort {
SortType::Size => module_read_cmd += " | sort -n -r -t ' ' -k2",
SortType::Name => module_read_cmd += " | sort -t ' ' -k1",
SortType::Dependent => module_read_cmd += " | sort -n -r -t ' ' -k3",
_ => {}
}
let modules_content = util::exec_cmd("sh", &["-c", &module_read_cmd])

View File

@ -102,6 +102,12 @@ pub fn parse_args() -> clap::ArgMatches<'static> {
.short("n")
.long("name")
.help("Sort modules by their names"),
)
.arg(
Arg::with_name("dependent")
.short("d")
.long("dependent")
.help("Sort modules by their dependent modules"),
),
)
.get_matches()