Skip to content

Commit

Permalink
Remove default paramater for Command
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaspustina committed Jan 5, 2020
1 parent 742cf5e commit a5c8a97
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 16 deletions.
8 changes: 8 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@
* [x] Error handling in binary
* [x] Find a nice logger
* [ ] Create linux and macos configuration
* macOS
* sw_vers
* softwareupdate -l
* http://www.brendangregg.com/USEmethod/use-macosx.html
* Linux
* https://www.cyberciti.biz/tips/top-linux-monitoring-tools.html
* http://www.brendangregg.com/USEmethod/use-linux.html

## Before 1.0

* Profiles, Categories,
* Config: Use defaults
* Use a abstract type to hold results
* Include Host information etc. that are currently in Report (maybe)
Expand Down
3 changes: 0 additions & 3 deletions contrib/osx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,19 @@ title = "Current Load"
description = "Current load and uptime"
command = "/usr/bin/uptime"
timeout = 1
default_run = true

[[command]]
name = "vm_stat"
title = "Virtual Memory statistics"
description = "Current memory usage and statistics in pages"
command = "vm_stat -c 5 1"
timeout = 5
default_run = true

[[command]]
name = "iostat"
title = "Kernel I/O statistics"
description = "Current I/O statistics per dev in KB"
command = "/usr/sbin/iostat -c 5 -K"
timeout = 5
default_run = true

# vim: set ft=toml:
13 changes: 1 addition & 12 deletions src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ pub type Result<T, E = Error> = std::result::Result<T, E>;
/// ```
/// # use usereport::command::{Command, CommandResult};
/// let command = Command::new("uname", r#"/usr/bin/uname -a"#, 5)
/// .title("Host OS")
/// .run_by_default(false);
/// .title("Host OS");
/// match command.exec() {
/// Ok(CommandResult::Success {
/// command: _,
Expand All @@ -50,7 +49,6 @@ pub struct Command {
pub(crate) args: Vec<String>,
#[serde(rename = "timeout")]
pub(crate) timeout_sec: u64,
pub(crate) default_run: bool,
}

fn de_ser_args<'de, D>(deserializer: D) -> ::std::result::Result<Vec<String>, D::Error>
Expand Down Expand Up @@ -90,7 +88,6 @@ impl Command {
description: None,
args,
timeout_sec,
default_run: true,
}
}

Expand All @@ -110,14 +107,6 @@ impl Command {
}
}

/// Set whether to run this command by default
pub fn run_by_default(self, value: bool) -> Command {
Command {
default_run: value,
..self
}
}

/// Execute this command
pub fn exec(self) -> Result<CommandResult> {
let mut p = Popen::create(
Expand Down
1 change: 0 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ default_run = true
Command::new("uname", "/usr/bin/uname -a", 1)
.title("Host OS")
.description("Basic host OS information")
.run_by_default(true),
);
let expected = Config { defaults, commands };

Expand Down

0 comments on commit a5c8a97

Please sign in to comment.