Dan Anglin
36acb1a324
- Add a new subcommand and FlagSet for creating new CV JSON files. - fix: close the file after reading the CV.
40 lines
711 B
Go
40 lines
711 B
Go
package main
|
|
|
|
import (
|
|
"embed"
|
|
"log"
|
|
"os"
|
|
)
|
|
|
|
type Runner interface {
|
|
Parse([]string) error
|
|
Name() string
|
|
Run() error
|
|
}
|
|
|
|
//go:embed templates/tex/*
|
|
var templates embed.FS
|
|
|
|
func main() {
|
|
commandMap := map[string]Runner{
|
|
"version": NewVersionCommand(),
|
|
"generate": NewGenerateCommand(),
|
|
"create": NewCreateCommand(),
|
|
}
|
|
|
|
subcommand := os.Args[1]
|
|
|
|
runner, ok := commandMap[subcommand]
|
|
|
|
if !ok {
|
|
log.Fatalf("ERROR: unknown subcommand '%s'.", subcommand)
|
|
}
|
|
|
|
if err := runner.Parse(os.Args[2:]); err != nil {
|
|
log.Fatalf("ERROR: unable to parse the command line flags; %v.", err)
|
|
}
|
|
|
|
if err := runner.Run(); err != nil {
|
|
log.Fatalf("ERROR: unable to run '%s'; %v.", runner.Name(), err)
|
|
}
|
|
}
|