-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:shikaan/shmux
- Loading branch information
Showing
15 changed files
with
516 additions
and
295 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Launch Package", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "auto", | ||
"program": "${fileDirname}/../main.go" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package scripts | ||
|
||
import ( | ||
"bufio" | ||
"fmt" | ||
"io" | ||
"strings" | ||
) | ||
|
||
func MakeHelp(file io.Reader) string { | ||
availableScripts := []string{} | ||
scanner := bufio.NewScanner(file) | ||
|
||
for scanner.Scan() { | ||
line := scanner.Text() | ||
isScriptLine, match, _ := readScript(line) | ||
|
||
if isScriptLine { | ||
availableScripts = append(availableScripts, match) | ||
} | ||
} | ||
|
||
return fmt.Sprintf(`usage: shmux [-config <path>] [-shell <path>] <script> -- [arguments ...] | ||
Available scripts: %s | ||
Run 'shmux -h' for details. | ||
`, strings.Join(availableScripts, ", ")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package scripts | ||
|
||
import ( | ||
"io" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func TestMakeHelp(t *testing.T) { | ||
type args struct { | ||
file io.Reader | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
includes string | ||
}{ | ||
{"returns the correct text", args{strings.NewReader("script:\n\tscript1\n\nanother:\n\tscript2")}, "script1, script2"}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := MakeHelp(tt.args.file); strings.Contains(got, tt.includes) { | ||
t.Errorf("MakeHelp() = %v, does not include %v", got, tt.includes) | ||
} | ||
}) | ||
} | ||
} |
Oops, something went wrong.