Dan Anglin
cee274318d
Create new FlagSets to create new subcommands. - The version subcommand prints the version and build info. - The generate subcommand generates the CV PDF documentation.
25 lines
436 B
Go
25 lines
436 B
Go
package cv
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
// NewCV returns a new CV value from the given JSON file.
|
|
func NewCV(path string) (CV, error) {
|
|
file, err := os.Open(path)
|
|
if err != nil {
|
|
return CV{}, fmt.Errorf("unable to open %s; %w", path, err)
|
|
}
|
|
|
|
decoder := json.NewDecoder(file)
|
|
|
|
var c CV
|
|
|
|
if err = decoder.Decode(&c); err != nil {
|
|
return CV{}, fmt.Errorf("unable to decode JSON data; %w", err)
|
|
}
|
|
|
|
return c, nil
|
|
}
|