Skip to content

Commit

Permalink
Merge pull request #218 from Arvintian/main
Browse files Browse the repository at this point in the history
Fix command params issue
  • Loading branch information
yottahmd authored Jul 29, 2022
2 parents d486db6 + 83b2d41 commit 5069982
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
23 changes: 14 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
bin:
mkdir ./bin

VERSION=$(shell date +'%y%m%d%H%M%S')
LDFLAGS=-X 'main.version=$(VERSION)'

.PHONY: build-dir
build-dir:
mkdir -p ./bin

.PHONY: build
build: build-admin bin
build: build-admin build-dir
go build -ldflags="$(LDFLAGS)" -o ./bin/dagu ./cmd/

.PHONY: build-admin
Expand All @@ -17,14 +18,14 @@ build-admin:
cp admin/dist/*.ttf ./internal/admin/handlers/web/assets/fonts/

.PHONY: server
server:
server: build-dir
go build -ldflags="$(LDFLAGS)" -o ./bin/dagu ./cmd/
go run -ldflags="$(LDFLAGS)" ./cmd/ server
./bin/dagu server

.PHONY: scheduler
scheduler:
scheduler: build-dir
go build -ldflags="$(LDFLAGS)" -o ./bin/dagu ./cmd/
go run -ldflags="$(LDFLAGS)" ./cmd/ scheduler
./bin/dagu scheduler

.PHONY: test
test: build
Expand All @@ -37,4 +38,8 @@ test-clean:

.PHONY: lint
lint:
golangci-lint run ./...
golangci-lint run ./...

.PHONY: clean
clean:
rm -rf bin admin/dist
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ require (
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/mattn/go-shellwords v1.0.12 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ github.com/jedib0t/go-pretty/v6 v6.3.1 h1:aOXiD9oqiuLH8btPQW6SfgtQN5zwhyfzZls8a6
github.com/jedib0t/go-pretty/v6 v6.3.1/go.mod h1:FMkOpgGD3EZ91cW8g/96RfxoV7bdeJyzXPYgz1L1ln0=
github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-shellwords v1.0.12 h1:M2zGm7EW6UQJvDeQxo4T51eKPurbeFbe8WtebGE2xrk=
github.com/mattn/go-shellwords v1.0.12/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/pkg/profile v1.6.0/go.mod h1:qBsxPvzyUincmltOk6iyRVxHYg4adc0OFOv72ZdLa18=
Expand Down
2 changes: 1 addition & 1 deletion internal/admin/handlers/web/templates/base.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dagu Admin Web</title>
<title>{{navbarTitle}}</title>
<script>
const API_URL = "";
function getConfig() {
Expand Down
10 changes: 9 additions & 1 deletion internal/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"strings"
"time"

"github.com/mattn/go-shellwords"
"github.com/yohamta/dagu/internal/constants"
)

Expand Down Expand Up @@ -64,7 +65,14 @@ func FormatDuration(t time.Duration, defaultVal string) string {
func SplitCommand(cmd string) (program string, args []string) {
vals := strings.SplitN(cmd, " ", 2)
if len(vals) > 1 {
return vals[0], strings.Split(vals[1], " ")
program = vals[0]
parser := shellwords.NewParser()
args, err := parser.Parse(vals[1])
if err != nil {
//if parse shell world error use all substring as args
return program, []string{vals[1]}
}
return program, args
}
return vals[0], []string{}
}
Expand Down

0 comments on commit 5069982

Please sign in to comment.