2024-03-19 14:05:26 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"io"
|
|
|
|
|
"os"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
os.Exit(Main(os.Stdout))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func Main(output io.Writer) int {
|
|
|
|
|
conf, err := InitConfig(output)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return Die(err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if conf.Showversion {
|
|
|
|
|
fmt.Fprintf(output, "This is gfn version %s\n", VERSION)
|
|
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if conf.Listshortcuts {
|
2024-03-19 18:12:02 +01:00
|
|
|
ListTemplates(output)
|
2024-03-19 14:05:26 +01:00
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-19 18:12:02 +01:00
|
|
|
if len(conf.Code) == 0 {
|
|
|
|
|
fmt.Fprintln(output, Usage)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if Exists(Templates, conf.Code) {
|
2024-03-19 14:05:26 +01:00
|
|
|
conf.Code = Templates[conf.Code]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
names, err := Generate(conf.Count, conf.Code)
|
2024-03-19 18:12:02 +01:00
|
|
|
if err != nil {
|
|
|
|
|
return Die(err)
|
2024-03-19 14:05:26 +01:00
|
|
|
}
|
|
|
|
|
|
2024-03-19 18:12:02 +01:00
|
|
|
if err = PrintColumns(names, output); err != nil {
|
|
|
|
|
return Die(err)
|
2024-03-19 14:05:26 +01:00
|
|
|
}
|
|
|
|
|
|
2024-03-19 18:12:02 +01:00
|
|
|
return 0
|
2024-03-19 14:05:26 +01:00
|
|
|
}
|