Skip to content

Commit

Permalink
Build CLI: Add running commands infos to logs
Browse files Browse the repository at this point in the history
Add logs entries with the running commands with their current
directory to the logs.
  • Loading branch information
AmmarAbouZor authored and marcmo committed Oct 11, 2024
1 parent d2fa88b commit feb9703
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Features:

* Check the latest version of this tool on the local repository and compare it to the installed one.
* Add the running process commands and their current directory to the logs.


# 0.2.5
Expand Down
19 changes: 15 additions & 4 deletions cli/src/spawner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,14 @@ pub async fn spawn(
combined_env_vars.extend(environment_vars);

let tracker = get_tracker();
let cmd_combined = command.combine();
let cmd_msg = format!("Running command: {cmd_combined}");
tracker.msg(job_def, cmd_msg);
let cwd_msg = format!("Running in directory: {}", cwd.display());
tracker.msg(job_def, cwd_msg);

let command_result = shell_tokio_command()
.arg(command.combine())
.arg(cmd_combined)
.current_dir(&cwd)
.envs(combined_env_vars)
.stdout(Stdio::piped())
Expand Down Expand Up @@ -198,13 +203,19 @@ pub async fn spawn_blocking(
let mut combined_env_vars = vec![(String::from("TERM"), String::from("xterm-256color"))];
combined_env_vars.extend(environment_vars);

let tracker = get_tracker();

let cmd_combined = command.combine();
let cmd_msg = format!("Running command: {cmd_combined}");
tracker.msg(job_def, cmd_msg);
let cwd_msg = format!("Running in directory: {}", cwd.display());
tracker.msg(job_def, cwd_msg);

let mut cmd = shell_std_command();
cmd.arg(command.combine());
cmd.arg(cmd_combined);
cmd.current_dir(&cwd);
cmd.envs(combined_env_vars);

let tracker = get_tracker();

let status = tracker.run_synchronously(job_def, cmd).await?;

Ok(SpawnResult {
Expand Down

0 comments on commit feb9703

Please sign in to comment.