allow specifying theme name for sample input file

This commit is contained in:
Sina Atalay 2024-02-24 22:23:35 +01:00
parent cb73d47321
commit 4142002d33
2 changed files with 32 additions and 23 deletions

View File

@ -470,9 +470,12 @@ def cli_command_render(
' "John Doe"[/bold green]' ' "John Doe"[/bold green]'
), ),
) )
def cli_command_new(full_name: Annotated[str, typer.Argument(help="Your full name")]): def cli_command_new(
full_name: Annotated[str, typer.Argument(help="Your full name")],
theme: Annotated[str, typer.Option(help="The theme of the CV")] = "classic",
):
"""Generate a YAML input file to get started.""" """Generate a YAML input file to get started."""
data_model = dm.get_a_sample_data_model(full_name) data_model = dm.get_a_sample_data_model(full_name, theme)
file_name = f"{full_name.replace(' ', '_')}_CV.yaml" file_name = f"{full_name.replace(' ', '_')}_CV.yaml"
file_path = pathlib.Path(file_name) file_path = pathlib.Path(file_name)

View File

@ -1099,7 +1099,9 @@ def read_input_file(
return rendercv_data_model return rendercv_data_model
def get_a_sample_data_model(name: str = "John Doe") -> RenderCVDataModel: def get_a_sample_data_model(
name: str = "John Doe", theme: str = "classic"
) -> RenderCVDataModel:
"""Return a sample data model for new users to start with. """Return a sample data model for new users to start with.
Args: Args:
@ -1135,7 +1137,7 @@ def get_a_sample_data_model(name: str = "John Doe") -> RenderCVDataModel:
], ],
), ),
], ],
"employment": [ "experience": [
ExperienceEntry( ExperienceEntry(
company="Apple Computer", company="Apple Computer",
position="Software Engineer, Intern", position="Software Engineer, Intern",
@ -1145,16 +1147,16 @@ def get_a_sample_data_model(name: str = "John Doe") -> RenderCVDataModel:
highlights=[ highlights=[
( (
"Reduced time to render the user's buddy list by 75% by" "Reduced time to render the user's buddy list by 75% by"
" implementing prediction algorithm." " implementing a prediction algorithm."
), ),
( (
"Implemented iChat integration with OS X Spotlight Search by" "Implemented iChat integration with OS X Spotlight Search by"
" creating tool which extracts metadata from saved chat" " creating a tool that extracts metadata from saved chat"
" transcripts and provides metadata to a system-wide search" " transcripts and provides metadata to a system-wide search"
" database." " database."
), ),
( (
"Redesigned chat file format and implemented backwards" "Redesigned chat file format and implemented backward"
" compatibility for search." " compatibility for search."
), ),
], ],
@ -1167,11 +1169,11 @@ def get_a_sample_data_model(name: str = "John Doe") -> RenderCVDataModel:
location="WA, USA", location="WA, USA",
highlights=[ highlights=[
( (
"Promoted to Lead Student Ambassador in Fall 2004, supervised" "Promoted to Lead Student Ambassador in the Fall of 2004, supervised"
" 10 - 15 Student Ambassadors." " 10 - 15 Student Ambassadors."
), ),
( (
"Created and taught Computer Science course, CSE 099: Software" "Created and taught a computer science course, CSE 099: Software"
" Design and Development." " Design and Development."
), ),
], ],
@ -1188,17 +1190,17 @@ def get_a_sample_data_model(name: str = "John Doe") -> RenderCVDataModel:
" (ctrl-tab) and extended it to tool windows." " (ctrl-tab) and extended it to tool windows."
), ),
( (
"Created service to provide gradient across VS and VS add-ins." "Created a service to provide gradient across VS and VS add-ins."
" Optimized service via caching." " Optimized service via caching."
), ),
"Programmer Productivity Research Center (Summers 2001, 2002)", "Programmer Productivity Research Center (Summers 2001, 2002)",
( (
"Built app to compute similarity of all methods in a code base," "Built app to compute the similarity of all methods in a code base,"
" reduced time from $\\mathcal{O}(n^2)$ to $\\mathcal{O}(n" " reduced time from $\\mathcal{O}(n^2)$ to $\\mathcal{O}(n"
" \\log n)$. " " \\log n)$. "
), ),
( (
"Created test case generation tool which creates random XML" "Created a test case generation tool that creates random XML"
" docs from XML Schema." " docs from XML Schema."
), ),
], ],
@ -1211,13 +1213,9 @@ def get_a_sample_data_model(name: str = "John Doe") -> RenderCVDataModel:
location="WA, USA", location="WA, USA",
highlights=[ highlights=[
( (
"Promoted to Lead Student Ambassador in Fall 2004, supervised" "Promoted to Lead Student Ambassador in the Fall of 2004, supervised"
" 10 - 15 Student Ambassadors." " 10 - 15 Student Ambassadors."
), ),
(
"Created and taught Computer Science course, CSE 099: Software"
" Design and Development."
),
], ],
), ),
], ],
@ -1261,7 +1259,7 @@ def get_a_sample_data_model(name: str = "John Doe") -> RenderCVDataModel:
" synchronized calendars, allowing users to schedule meetings" " synchronized calendars, allowing users to schedule meetings"
" with other users." " with other users."
), ),
"Used C#.NET, SQL and XML.", "Used C#.NET, SQL, and XML.",
], ],
), ),
NormalEntry( NormalEntry(
@ -1269,8 +1267,8 @@ def get_a_sample_data_model(name: str = "John Doe") -> RenderCVDataModel:
date="2002", date="2002",
highlights=[ highlights=[
( (
"Developed a UNIX-style OS with scheduler, file system, text" "Developed a UNIX-style OS with a scheduler, file system, text"
" editor and calculator." " editor, and calculator."
), ),
"Used C.", "Used C.",
], ],
@ -1284,7 +1282,7 @@ def get_a_sample_data_model(name: str = "John Doe") -> RenderCVDataModel:
OneLineEntry( OneLineEntry(
name="Third Prize, Senior Design Projects", name="Third Prize, Senior Design Projects",
details=( details=(
"Awarded 3rd prize for Synchronized Calendar project, out of 100" "Awarded 3rd prize for a synchronized calendar project out of 100"
" projects." " projects."
), ),
), ),
@ -1317,8 +1315,16 @@ def get_a_sample_data_model(name: str = "John Doe") -> RenderCVDataModel:
sections=sections, # type: ignore sections=sections, # type: ignore
) )
# design = ClassicThemeOptions(theme="classic", show_timespan_in=["Employment"]) if theme not in available_themes:
design = Sb2novThemeOptions(theme="sb2nov") raise ValueError(
f"The theme should be one of the following: {available_themes}! The"
f" provided theme is {theme}."
)
if theme == "classic":
design = ClassicThemeOptions(theme="classic", show_timespan_in=["Experience"])
else:
design = rendercv_design_validator.validate_python({"theme": theme}) # type: ignore
return RenderCVDataModel(cv=cv, design=design) return RenderCVDataModel(cv=cv, design=design)