Skip to content

Commit b0b732d

Browse files
GaetanLepagepvolok
authored andcommitted
Add name optional argument to add-proc
This allows to add a process and to give it a name directly
1 parent a985fd2 commit b0b732d

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ Commands are encoded as yaml. Available commands:
312312
- `{c: restart-proc}`
313313
- `{c: force-restart-proc}`
314314
- `{c: show-add-proc}`
315-
- `{c: add-proc, cmd: "<SHELL COMMAND>"}`
315+
- `{c: add-proc, cmd: "<SHELL COMMAND>", name: "<PROC NAME>"}`
316316
- `{c: duplicate-proc}`
317317
- `{c: show-remove-proc}`
318318
- `{c: remove-proc, id: "<PROCESS ID>"}`

src/app.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -566,11 +566,15 @@ impl App {
566566
self.modal = Some(AddProcModal::new(self.ev_tx.clone()).boxed());
567567
loop_action.render();
568568
}
569-
AppEvent::AddProc { cmd } => {
569+
AppEvent::AddProc { cmd, name } => {
570+
let name: String = match name {
571+
Some(s) => s.to_string(),
572+
None => cmd.to_string(),
573+
};
570574
let proc_handle = create_proc(
571-
cmd.to_string(),
575+
name.clone(),
572576
&ProcConfig {
573-
name: cmd.to_string(),
577+
name: name.clone(),
574578
cmd: CmdConfig::Shell {
575579
shell: cmd.to_string(),
576580
},

src/event.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub enum AppEvent {
3131
ForceRestartProc,
3232
ShowAddProc,
3333
ShowRenameProc,
34-
AddProc { cmd: String },
34+
AddProc { cmd: String, name: Option<String> },
3535
DuplicateProc,
3636
ShowRemoveProc,
3737
RemoveProc { id: usize },
@@ -79,7 +79,7 @@ impl AppEvent {
7979
AppEvent::ForceRestartProc => "Force restart".to_string(),
8080
AppEvent::ShowAddProc => "New process dialog".to_string(),
8181
AppEvent::ShowRenameProc => "Rename process dialog".to_string(),
82-
AppEvent::AddProc { cmd } => format!("New process `{}`", cmd),
82+
AppEvent::AddProc { cmd, name } => format!("New process `{}`", cmd),
8383
AppEvent::DuplicateProc => "Duplicate current process".to_string(),
8484
AppEvent::ShowRemoveProc => "Remove process dialog".to_string(),
8585
AppEvent::RemoveProc { id } => format!("Remove process by id {}", id),

0 commit comments

Comments
 (0)