Skip to content

Commit

Permalink
fix: remove %pistol-extra% arguments when not passed to pistol (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas-mior authored Aug 27, 2021
1 parent 10a56e0 commit 4c9a62c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions previewer.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,19 +173,21 @@ func (p *Previewer) Write(w io.Writer) (error) {
// We try to convert the string found in the argument to a
// number.
auxInt, err := strconv.Atoi(arg[loc[2]:loc[3]])
current := arg[loc[0]:loc[1]]
if (err == nil && len(p.Extras) > auxInt) {
// substitute the %pistol-extra[#]% argument in the
// final CLI string.
current := arg[loc[0]:loc[1]]
argAux = strings.ReplaceAll(argAux, current, p.Extras[auxInt])
} else {
continue
argAux = strings.ReplaceAll(argAux, current, "")
}
}
} else {
argAux = strings.ReplaceAll(argAux, "%pistol-filename%", replStr)
}
argsOut = append(argsOut, argAux)
if(len(argAux) > 0) {
argsOut = append(argsOut, argAux)
}
}

if p.Command == "sh:" {
Expand Down

0 comments on commit 4c9a62c

Please sign in to comment.