allowed file to be entered as argument

This commit is contained in:
John O'Keefe 2023-12-09 11:51:31 -05:00
parent 52714efc92
commit d38cfc8036

16
main.go
View File

@ -21,10 +21,18 @@ func main() {
Error(err)
// Get name of file to be processed.
pterm.Printf(pterm.Cyan("What is the name of the file in this directory?: "))
reader := bufio.NewReader(os.Stdin)
input, err := reader.ReadString('\n')
Error(err)
args := os.Args[1:]
var input string
if len(args) > 0 {
input = args[0]
} else {
pterm.Printf(pterm.Cyan("What is the name of the file in this directory?: "))
reader := bufio.NewReader(os.Stdin)
input, err = reader.ReadString('\n')
Error(err)
}
// Create upcs array and push all upc strings into it
input = strings.TrimSpace(input)