Skip to content

Commit

Permalink
Add info flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Theo-Hafsaoui committed Dec 22, 2024
1 parent 9fb72da commit e5c6596
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 42 deletions.
6 changes: 3 additions & 3 deletions assets/latex/template/template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@

%VARS%
\begin{center}
\textbf{\Huge \scshape \textcolor{nblue}{\Name \ \Firstname}} \\ \vspace{1pt}
\textbf{\Huge \scshape \textcolor{nblue}{\Name \ \FirstName}} \\ \vspace{1pt}
\small \Number \ $|$ \href{mailto:\Mail}{\underline{\Mail}} \\
\href{https:\Linkedin}{\underline{linkedin.com/in/\Name}} $|$
\href{https:\Github}{\underline{github.com/\Name}}
\href{\LinkedIn}{\underline{linkedin.com/in/\Name}} $|$
\href{\GitHub}{\underline{github.com/\Name}}
\end{center}

%-----------EDUCATION-----------
Expand Down
72 changes: 40 additions & 32 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,42 +1,50 @@
package cmd

import (
"anemon/internal/adapters/input"
"github.com/spf13/cobra"
"os"
"anemon/internal/adapters/input"
"github.com/spf13/cobra"
"os"
)

var rootCmd = &cobra.Command{
Use: "anemon",
Short: "A CV generator",
Long: `This CLI tool, automates the generation of customized CVs from Markdown files based on a specified configuration.`,
RunE: func(cmd *cobra.Command, args []string) error {
threshold, err := cmd.Flags().GetInt("threshold")
if err != nil {
return err
}
input.ChangeOverflowThreshold(threshold)

generate, err := cmd.Flags().GetBool("generate")
if err != nil {
return err
}
if generate {
root, err := os.Getwd()
if err != nil {
return err
}
return input.GenerateCVFromMarkDownToLatex(root)
}

return nil
},
Use: "anemon",
Short: "A CV generator",
Long: `This CLI tool, automates the generation of customized CVs from Markdown files based on a specified configuration.`,
RunE: func(cmd *cobra.Command, args []string) error {
threshold, err := cmd.Flags().GetInt("threshold")
if err != nil { return err }

root, err := os.Getwd()
if err != nil { return err }

if err != nil {
return err
}
input.ChangeOverflowThreshold(threshold)

generate, err := cmd.Flags().GetBool("generate")
if err != nil { return err }

if generate {
return input.GenerateCVFromMarkDownToLatex(root)
}

info, err := cmd.Flags().GetBool("cvInfo")
if err != nil { return err }
if info{
input.PrintAllCvs(root)
return nil
}

return nil
},
}

func Execute() {
rootCmd.Flags().IntP("threshold", "t", 1, "Set the page overflow threshold (default 1)")
rootCmd.Flags().BoolP("generate", "g", false, "Generate a CV")
if err := rootCmd.Execute(); err != nil {
os.Exit(1)
}
rootCmd.Flags().IntP("threshold", "t", 1, "Set the page overflow threshold (default 1)")
rootCmd.Flags().BoolP("generate", "g", false, "Generate a CV")
rootCmd.Flags().BoolP("cvInfo", "i", false, "Get all the info of all the cvs")
if err := rootCmd.Execute(); err != nil {
os.Exit(1)
}
}
6 changes: 6 additions & 0 deletions internal/adapters/input/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@ func GenerateCVFromMarkDownToLatex(root string) error {
func ChangeOverflowThreshold(newThreshold int) {
core.SetOverflowThreshold(newThreshold)
}
// Print info in the prompt for all the cvs
func PrintAllCvs(root string) {
source := MarkdownSource{}
core.GetInfoAllCvs(root,&source)
}

8 changes: 4 additions & 4 deletions internal/adapters/input/markdown_tree_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ func (*MarkdownSource) GetCVsFrom(root string) ([]core.CV, error) {
has_been_inside_dir = false
}
current_lang = info.Name()
cvs = append(cvs, core.CV{Lang: current_lang})
if current_lang != "cv"{
cvs = append(cvs, core.CV{Lang: current_lang})
}
}
if !info.IsDir() && strings.HasSuffix(info.Name(), ".md") {
has_been_inside_dir = true
Expand All @@ -50,10 +52,8 @@ func (*MarkdownSource) GetCVsFrom(root string) ([]core.CV, error) {
if err != nil {
return err
}

new_section := core.Section{Title: strings.TrimRight(info.Name(), ".md"),
Paragraphes: getParagrapheFrom(string(content))}

Paragraphes: getParagrapheFrom(string(content))}
current_sections = append(current_sections, new_section)
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion internal/adapters/output/latex_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (*LatexReader) ReadCVTemplate(root string, params core.Params) (string, err
return ApplyInfoToTemplate(string(file), params), nil
}

// Apply general information(name, mail..) to a template
// Apply general information(name, mail...) to a template
func ApplyInfoToTemplate(template string, params core.Params) string {
var varsBuilder strings.Builder
infoValue := reflect.ValueOf(params.Info)
Expand Down
11 changes: 11 additions & 0 deletions internal/core/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,17 @@ func (s *BuilderService) GetService() CVService {
}
}

//Get all info of the cvs and prompt them in the stdout
func GetInfoAllCvs(root string, source Source){
cvs, err := source.GetCVsFrom(root)
if err != nil{
slog.Warn(err.Error())
}
for _,cv := range cvs{
cv.Print()
}
}

// Set the threshold value dynamically
func SetOverflowThreshold(newThreshold int) {
TresholdPageOverFlow.mutex.Lock()
Expand Down
4 changes: 2 additions & 2 deletions params.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ info:
firstname: Vincent
number: "+33 42 42 42 42 42"
mail: vincent.anemon@example.com
github: vanemon
linkedin: vincent-anemon-linkedin
github: https://github.com/anemon
linkedin: https://www.linkedin.com/anemon

variante:
webDev:
Expand Down

0 comments on commit e5c6596

Please sign in to comment.