Skip to content

Commit

Permalink
Make sure goal/tasks replacements can be disabled. Fixes #19
Browse files Browse the repository at this point in the history
  • Loading branch information
aalmiray committed Sep 16, 2020
1 parent 0db4451 commit a1172cf
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 19 deletions.
16 changes: 4 additions & 12 deletions gum/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,27 +74,19 @@ func newConfig() *Config {
}

func (c *Config) setQuiet(b bool) {
if b {
c.general.quiet = b
}
c.general.quiet = b
}

func (c *Config) setDebug(b bool) {
if b {
c.general.debug = b
}
c.general.debug = b
}

func (g *gradle) setReplace(b bool) {
if b {
g.replace = b
}
g.replace = b
}

func (m *maven) setReplace(b bool) {
if b {
m.replace = b
}
m.replace = b
}

func (c *Config) merge(other *Config) {
Expand Down
4 changes: 2 additions & 2 deletions gum/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ func GrabFlag(f string, args []string) (bool, []string) {
return false, args
}

func findFlag(f string, args []string) bool {
func findFlag(flag string, args []string) bool {
if len(args) == 0 {
// no args to be checked
return false
}

for i := range args {
s := args[i]
if s == f {
if flag == s {
return true
}
}
Expand Down
7 changes: 5 additions & 2 deletions gum/gradle.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,14 @@ func (c *GradleCommand) doConfigureGradle() {
banner := make([]string, 0)
banner = append(banner, "Using gradle at '"+c.executable+"'")
nearest, oargs := GrabFlag("-gn", c.args)
debugSet := findFlag("-gd", oargs)
debug, oargs := GrabFlag("-gd", oargs)
replaceSet := findFlag("-gr", args)
replaceSet := findFlag("-gr", oargs)
skipReplace, oargs := GrabFlag("-gr", oargs)

c.config.setDebug(debug)
if debugSet {
c.config.setDebug(debug)
}
if replaceSet {
c.config.gradle.setReplace(!skipReplace)
}
Expand Down
6 changes: 5 additions & 1 deletion gum/jbang.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ func (c *JbangCommand) doConfigureJbang() {

banner := make([]string, 0)
banner = append(banner, "Using jbang at '"+c.executable+"'")

debugSet := findFlag("-gd", c.args)
debug, oargs := GrabFlag("-gd", c.args)

c.config.setDebug(debug)
if debugSet {
c.config.setDebug(debug)
}

if len(c.explicitSourceFile) > 0 {
banner = append(banner, "to run sourceFile '"+c.explicitSourceFile+"':")
Expand Down
7 changes: 5 additions & 2 deletions gum/maven.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,14 @@ func (c *MavenCommand) doConfigureMaven() {
banner := make([]string, 0)
banner = append(banner, "Using maven at '"+c.executable+"'")
nearest, oargs := GrabFlag("-gn", c.args)
debugSet := findFlag("-gd", oargs)
debug, oargs := GrabFlag("-gd", oargs)
replaceSet := findFlag("-gr", args)
replaceSet := findFlag("-gr", oargs)
skipReplace, oargs := GrabFlag("-gr", oargs)

c.config.setDebug(debug)
if debugSet {
c.config.setDebug(debug)
}
if replaceSet {
c.config.maven.setReplace(!skipReplace)
}
Expand Down

0 comments on commit a1172cf

Please sign in to comment.