Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove %pistol-extra% arguments when not passed to pistol #68

Merged
merged 1 commit into from
Aug 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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