Skip to content

Commit

Permalink
Clean comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jeevithakannan2 committed Sep 19, 2024
1 parent 1c932fa commit d52c4a3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
7 changes: 3 additions & 4 deletions tui/src/running_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,18 @@ impl RunningCommand {
pub fn new(commands: Vec<Command>) -> Self {
let pty_system = NativePtySystem::default();

// Create a command to execute all the selected commands
// Build the command based on the provided Command enum variant
let mut cmd: CommandBuilder = CommandBuilder::new("sh");
cmd.arg("-c");

// Initialize an empty string to hold the merged commands
// All the merged commands are passed as a single argument to reduce the overhead of rebuilding the command arguments for each and every command
let mut script = String::new();
for command in commands {
match command {
Command::Raw(prompt) => script.push_str(&format!("{}\n", prompt)), // Merge raw commands
Command::Raw(prompt) => script.push_str(&format!("{}\n", prompt)),
Command::LocalFile(file) => {
if let Some(parent) = file.parent() {
script.push_str(&format!("cd {}\n", parent.display())); // Merge local file path
script.push_str(&format!("cd {}\n", parent.display()));
}
script.push_str(&format!("sh {}\n", file.display()));
}
Expand Down
5 changes: 2 additions & 3 deletions tui/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,15 +279,15 @@ impl AppState {
match key.code {
KeyCode::Tab => {
if self.current_tab.selected().unwrap() == self.tabs.len() - 1 {
self.current_tab.select_first(); // Select first tab when it is at last
self.current_tab.select_first();
} else {
self.current_tab.select_next();
}
self.refresh_tab();
}
KeyCode::BackTab => {
if self.current_tab.selected().unwrap() == 0 {
self.current_tab.select(Some(self.tabs.len() - 1)); // Select last tab when it is at first
self.current_tab.select(Some(self.tabs.len() - 1));
} else {
self.current_tab.select_previous();
}
Expand Down Expand Up @@ -525,7 +525,6 @@ impl AppState {

fn handle_enter(&mut self) {
if self.selected_item_is_cmd() {
// If no commands are selected, run the selected by pushing them into vector
if self.selected_commands.is_empty() {
if let Some(cmd) = self.get_selected_command() {
self.selected_commands.push(cmd);
Expand Down

0 comments on commit d52c4a3

Please sign in to comment.