add switch to allow suffix on output file

This commit is contained in:
sammiq 2018-10-14 17:58:40 +11:00
parent 9034b44053
commit 2426f65e48
2 changed files with 10 additions and 2 deletions

View File

@ -35,6 +35,7 @@ Usage
dec-decode [OPTIONS] Files...
Application Options:
-s, --suffix= add a suffix to the output file
-v, --verbose show lots more information than is probably necessary
Help Options:

View File

@ -11,7 +11,8 @@ import (
)
var opts struct {
Verbose bool `short:"v" long:"verbose" description:"show lots more information than is probably necessary"`
Suffix string `short:"s" long:"suffix" description:"add a suffix to the output file"`
Verbose bool `short:"v" long:"verbose" description:"show lots more information than is probably necessary"`
Positional struct {
Files []string `description:"list of files to decode" required:"true"`
} `positional-args:"true" required:"true"`
@ -35,7 +36,13 @@ func main() {
} else {
outPath = path.Join(".", fileName+".iso")
}
//outPath += ".dmp"
if opts.Suffix != "" {
if !strings.HasPrefix(opts.Suffix, ".") {
outPath += "."
}
outPath += opts.Suffix
}
signature := readSignature(fin)
fin.Seek(0, io.SeekStart)