| 1 | package App::Saisons::Launcher; | ||||||||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||
| 4 | 0 | ▶ | sub launch_cmd { | ||||||||||||||||||||||||
|
Subroutine
launch_cmd: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||
| 5 | 0 | my ($cmd, $cwd, $launcher, $title) = @_; | |||||||||||||||||||||||||
| 6 | 0 | ▶ | $title //= 'saisons'; | ||||||||||||||||||||||||
|
Condition0%0/2
$title //= "saisons"
MC/DC0%0/1
$title //= "saisons"
$title
Truth table0%0/2
A
A= $title
| |||||||||||||||||||||||||||
| 7 | 0 | ▶ | if ($launcher eq 'tmux') { | ||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||
| 8 | 0 | system('tmux', 'new-window', '-c', $cwd, $cmd); | |||||||||||||||||||||||||
| 9 | } | ||||||||||||||||||||||||||
| 10 | elsif ($launcher eq 'screen') { | ||||||||||||||||||||||||||
| 11 | 0 | system('screen', '-X', 'screen', '-t', substr($title, 0, 20), | |||||||||||||||||||||||||
| 12 | 'bash', '-c', "$cmd; exec bash"); | ||||||||||||||||||||||||||
| 13 | } | ||||||||||||||||||||||||||
| 14 | elsif ($launcher eq 'gnome-terminal') { | ||||||||||||||||||||||||||
| 15 | 0 | system('gnome-terminal', '--tab', "--working-directory=$cwd", | |||||||||||||||||||||||||
| 16 | '--', 'bash', '--login', '-c', $cmd); | ||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||
| 18 | elsif ($launcher eq 'iterm') { | ||||||||||||||||||||||||||
| 19 | 0 | my $escaped = _applescript_quote($cmd); | |||||||||||||||||||||||||
| 20 | 0 | system('osascript', '-e', qq{tell application "iTerm2"\ntell current window\ncreate tab with default profile\ntell current session of current tab\nwrite text $escaped\nend tell\nend tell\nend tell}); | |||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||
| 22 | elsif ($launcher eq 'terminal-app') { | ||||||||||||||||||||||||||
| 23 | 0 | my $escaped = _applescript_quote($cmd); | |||||||||||||||||||||||||
| 24 | 0 | system('osascript', '-e', qq{tell application "Terminal"\ndo script $escaped\nactivate\nend tell}); | |||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||
| 26 | else { | ||||||||||||||||||||||||||
| 27 | 0 | system('bash', '-c', $cmd); | |||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||
| 30 | 0 | ▶ | sub _applescript_quote { | ||||||||||||||||||||||||
|
Subroutine
_applescript_quote: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||
| 31 | 0 | my ($str) = @_; | |||||||||||||||||||||||||
| 32 | 0 | $str =~ s/\\/\\\\/g; | |||||||||||||||||||||||||
| 33 | 0 | $str =~ s/"/\\"/g; | |||||||||||||||||||||||||
| 34 | 0 | return qq{"$str"}; | |||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||
| 36 | 2 | 1; | |||||||||||||||||||||||||