Rewrite shell cmd parser

This commit is contained in:
Alex X
2023-10-25 16:49:01 +03:00
parent 041ce885c7
commit f291f1d827
2 changed files with 36 additions and 25 deletions

18
pkg/shell/shell_test.go Normal file
View File

@@ -0,0 +1,18 @@
package shell
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestQuoteSplit(t *testing.T) {
s := `
python "-c" 'import time
print("time", time.time())'
`
require.Equal(t, []string{"python", "-c", "import time\nprint(\"time\", time.time())"}, QuoteSplit(s))
s = `ffmpeg -i video="0" -i "DeckLink SDI (2)"`
require.Equal(t, []string{"ffmpeg", "-i", "video=\"0\"", "-i", "DeckLink SDI (2)"}, QuoteSplit(s))
}