Skip to content

Commit

Permalink
refactor(cli): Move init functions to its own module
Browse files Browse the repository at this point in the history
  • Loading branch information
Estrada Irribarra, Rodrigo Andres committed Oct 28, 2024
1 parent e4f4b92 commit 9441073
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions storycraftr/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ def init(
genre=genre,
behavior_content=behavior_content,
reference_author=reference_author,
cli_name=cli_name,
)
elif cli_name == "papercraftr":
init_structure_paper(
Expand All @@ -228,6 +229,7 @@ def init(
author=author,
keywords=keywords,
behavior_content=behavior_content,
cli_name=cli_name,
)


Expand Down
4 changes: 4 additions & 0 deletions storycraftr/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def init_structure_story(
genre,
behavior_content,
reference_author,
cli_name,
):
"""
Initializes the StoryCraftr project structure by creating necessary files and folders.
Expand All @@ -73,6 +74,7 @@ def init_structure_story(
"genre": genre,
"license": license,
"reference_author": reference_author,
"cli_name": cli_name,
}
config_file = Path(book_path) / "storycraftr.json"
config_file.write_text(json.dumps(config_data, indent=4), encoding="utf-8")
Expand Down Expand Up @@ -113,6 +115,7 @@ def init_structure_paper(
reference_author,
keywords,
behavior_content,
cli_name,
):
"""
Initializes the PaperCraftr project structure by creating necessary files and folders.
Expand All @@ -137,6 +140,7 @@ def init_structure_paper(
"default_author": author,
"reference_author": reference_author,
"keywords": keywords,
"cli_name": cli_name,
}
config_file = Path(paper_path) / "papercraftr.json"
config_file.write_text(json.dumps(config_data, indent=4), encoding="utf-8")
Expand Down
4 changes: 4 additions & 0 deletions storycraftr/utils/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ class BookConfig(NamedTuple):
genre: str
license: str
reference_author: str
keywords: str
cli_name: str


def load_book_config(book_path: str) -> BookConfig:
Expand Down Expand Up @@ -108,6 +110,8 @@ def load_book_config(book_path: str) -> BookConfig:
genre=data["genre"],
license=data["license"],
reference_author=data["reference_author"],
keywords=data["keywords"],
cli_name=data["cli_name"],
)
except (FileNotFoundError, NotADirectoryError):
console.print(
Expand Down

0 comments on commit 9441073

Please sign in to comment.