(argv: I)
| 35 | } |
| 36 | |
| 37 | pub fn run_cli<I, T>(argv: I) -> Result<i32> |
| 38 | where |
| 39 | I: IntoIterator<Item = T>, |
| 40 | T: Into<OsString> + Clone, |
| 41 | { |
| 42 | env_logger::builder() |
| 43 | .parse_env(env_logger::Env::new().filter_or("CODSPEED_LOG", "info")) |
| 44 | .format_timestamp(None) |
| 45 | .init(); |
| 46 | crate::init_libbpf_logging(); |
| 47 | |
| 48 | let cli = Cli::parse_from(argv); |
| 49 | |
| 50 | match cli.command { |
| 51 | Commands::Track { |
| 52 | command, |
| 53 | output: out_dir, |
| 54 | ipc_server, |
| 55 | } => { |
| 56 | debug!("Starting memtrack for command: {command}"); |
| 57 | |
| 58 | let status = |
| 59 | track_command(&command, ipc_server, &out_dir).context("Failed to track command")?; |
| 60 | |
| 61 | Ok(status.code().unwrap_or(1)) |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | /// Get the original user's UID and GID when running under sudo. |
| 67 | /// Returns None if not running under sudo or if the environment variables are not set. |
no test coverage detected