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 9457c86
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 64 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)
}
}
4 changes: 2 additions & 2 deletions cv/eng/education.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Master's in Computer Science, Software Engineering
## [Link to Master's Program](https://www.univ-smith.edu/masters-software-engineering)
## https://www.univ-smith.edu/masters-software-engineering
### University of Smith
#### 2024

# Bachelor's in Computer Science
## [Link to Bachelor's Program](https://www.univ-smith.edu/bachelors-computer-science)
## https://www.univ-smith.edu/bachelors-computer-science
### University of Smith
#### 2024
4 changes: 2 additions & 2 deletions cv/eng/project.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Project A
## Language A, Framework A, Database A, Version Control A
### [Link to Repository](https://github.com/ExampleUser/projectA)
### https://github.com/ExampleUser/projectA
- Developed using Language A and Framework A, with Database A for data management.
- Executed in an agile environment, focusing on collaborative practices such as Version Control A Flow, Pull Requests, Kanban, and Continuous Integration.

# Project B
## Language B, ORM B, Containerization Tool B, API Security B
### [Link to Repository](https://github.com/ExampleUser/projectB)
### https://github.com/ExampleUser/projectB
- Designed and developed a specialized tool using Language B, Containerization Tool B, API Communication B, and API Security B.
- Separated front-end and back-end using Containerization Tool B, with orchestration handled by Container Orchestration B.
- Ensured secure communication between components via a RESTful API with API Security B tokens.
Expand Down
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
49 changes: 31 additions & 18 deletions internal/core/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,37 @@ func getScore(item string, keywords []string) int {
return score
}

//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()
defer TresholdPageOverFlow.mutex.Unlock()
TresholdPageOverFlow.value = newThreshold
}

// Get the current threshold value
func GetOverflowThreshold() int {
TresholdPageOverFlow.mutex.Lock()
defer TresholdPageOverFlow.mutex.Unlock()
return TresholdPageOverFlow.value
}

func init() {
TresholdPageOverFlow.value = 1
}

//--Builder--

func (cv *BuilderService) SetRoot(root string) {
cv.root = root
}
Expand Down Expand Up @@ -236,21 +267,3 @@ func (s *BuilderService) GetService() CVService {
compiler: s.compiler,
}
}

// Set the threshold value dynamically
func SetOverflowThreshold(newThreshold int) {
TresholdPageOverFlow.mutex.Lock()
defer TresholdPageOverFlow.mutex.Unlock()
TresholdPageOverFlow.value = newThreshold
}

// Get the current threshold value
func GetOverflowThreshold() int {
TresholdPageOverFlow.mutex.Lock()
defer TresholdPageOverFlow.mutex.Unlock()
return TresholdPageOverFlow.value
}

func init() {
TresholdPageOverFlow.value = 1
}
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 9457c86

Please sign in to comment.