feat: ability to specify a current employment
This commit allows the user to specify a company that they are currently employed at. Changes include: - add present field to the Duration type. - add durationToString function to output the duration type as a formatted string. - if the present field is used and the value is either 'true' or 'yes' (case insensitive) this will be reflected on the CV. - add durationToString to fmap. - updated CV template to use the durationToString function.
This commit is contained in:
parent
e9a2a749f9
commit
04162a27bc
3 changed files with 25 additions and 6 deletions
22
main.go
22
main.go
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
|
@ -22,8 +23,9 @@ func main() {
|
|||
cvOutputPath := cvOutputDir + cvOutputFileName
|
||||
|
||||
fmap := template.FuncMap{
|
||||
"notLastElement": notLastElement,
|
||||
"join": join,
|
||||
"notLastElement": notLastElement,
|
||||
"join": join,
|
||||
"durationToString": durationToString,
|
||||
}
|
||||
|
||||
// Read the JSON data
|
||||
|
@ -79,3 +81,19 @@ func notLastElement(pos, length int) bool {
|
|||
func join(s []string) string {
|
||||
return strings.Join(s, " ")
|
||||
}
|
||||
|
||||
// durationToString outputs the employment/education
|
||||
// duration as a formatted string.
|
||||
func durationToString(d Duration) string {
|
||||
start := fmt.Sprintf("%s, %s", d.Start.Month, d.Start.Year)
|
||||
present := strings.ToLower(d.Present)
|
||||
end := ""
|
||||
|
||||
if present == "yes" || present == "true" {
|
||||
end = "Present"
|
||||
} else {
|
||||
end = fmt.Sprintf("%s, %s", d.End.Month, d.End.Year)
|
||||
}
|
||||
|
||||
return start + " - " + end
|
||||
}
|
||||
|
|
5
model.go
5
model.go
|
@ -41,8 +41,9 @@ type Experience struct {
|
|||
}
|
||||
|
||||
type Duration struct {
|
||||
Start Date `json:"start"`
|
||||
End Date `json:"end"`
|
||||
Start Date `json:"start"`
|
||||
End Date `json:"end"`
|
||||
Present string `json:"present"`
|
||||
}
|
||||
|
||||
type Date struct {
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
\section{EXPERIENCE}
|
||||
<<- range .Employment>>
|
||||
\jobsection{<<.Company>>}{<<.Location>>}{<<.JobTitle>>}{<<.Duration.Start.Month>>, <<.Duration.Start.Year>> - <<.Duration.End.Month>>, <<.Duration.End.Year>>}
|
||||
\jobsection{<<.Company>>}{<<.Location>>}{<<.JobTitle>>}{<<durationToString .Duration>>}
|
||||
\startitemize
|
||||
<<range .Details>>
|
||||
\item <<.>>
|
||||
|
@ -38,7 +38,7 @@
|
|||
|
||||
\section{EDUCATION}
|
||||
<<range .Education ->>
|
||||
\jobsection{<<.School>>}{<<.Location>>}{<<.Qualification>>}{<<.Duration.Start.Month>>, <<.Duration.Start.Year>> - <<.Duration.End.Month>>, <<.Duration.End.Year>>}
|
||||
\jobsection{<<.School>>}{<<.Location>>}{<<.Qualification>>}{<<durationToString .Duration>>}
|
||||
\startitemize
|
||||
<<range .Details>>
|
||||
\item <<.>>
|
||||
|
|
Loading…
Reference in a new issue