allowed file to be entered as argument
This commit is contained in:
parent
52714efc92
commit
d38cfc8036
16
main.go
16
main.go
@ -21,10 +21,18 @@ func main() {
|
|||||||
Error(err)
|
Error(err)
|
||||||
|
|
||||||
// Get name of file to be processed.
|
// Get name of file to be processed.
|
||||||
pterm.Printf(pterm.Cyan("What is the name of the file in this directory?: "))
|
args := os.Args[1:]
|
||||||
reader := bufio.NewReader(os.Stdin)
|
|
||||||
input, err := reader.ReadString('\n')
|
var input string
|
||||||
Error(err)
|
|
||||||
|
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
|
// Create upcs array and push all upc strings into it
|
||||||
input = strings.TrimSpace(input)
|
input = strings.TrimSpace(input)
|
||||||
|
Loading…
Reference in New Issue
Block a user