|
3 | 3 | from website.posts import concatenate_drafts, create_new_post
|
4 | 4 | from website.task_helpers import check_project_root
|
5 | 5 |
|
6 |
| -app = typer.Typer(add_completion=False) |
7 |
| - |
8 |
| - |
9 |
| -@app.command() |
10 |
| -def new_post(title: str, series=None, quarto=False): |
11 |
| - """ |
12 |
| - Create a new post with a given title under a specified category. |
13 |
| - Optionally, specify a series name. |
14 |
| - Params: |
15 |
| - "title": "The title of the blog post you want to create." |
16 |
| - "series": "The series to which the blog post belongs (optional)." |
17 |
| - "quarto": "Initialize a quarto_document, defaults to False" |
18 |
| - """ |
| 6 | +app = typer.Typer( |
| 7 | + add_completion=False, help="Utility helpers for working on my website." |
| 8 | +) |
| 9 | + |
| 10 | + |
| 11 | +@app.command(help="Create a new (series) post with a given title.") |
| 12 | +def new_post( |
| 13 | + title: str = typer.Option(help="The title of the blog."), |
| 14 | + series: str |
| 15 | + | None = typer.Option( |
| 16 | + help="The series the blog post entry belongs to.", default=None |
| 17 | + ), |
| 18 | + quarto: bool = typer.Option( |
| 19 | + help="Initialize a quarto_document instead of regular markdown", default=False |
| 20 | + ), |
| 21 | +): |
19 | 22 | check_project_root()
|
20 | 23 | create_new_post(title, series, quarto)
|
21 | 24 |
|
22 | 25 |
|
23 |
| -@app.command() |
| 26 | +@app.command(help="Concatenate all draft posts into a single markdown file.") |
24 | 27 | def list_draft_posts(
|
25 |
| - file_out="current_draft_posts.md", |
26 |
| - search_directory="content/post", |
27 |
| - search_string="draft: true", |
| 28 | + file_out: str = typer.Option( |
| 29 | + help="The output file name for concatenated drafts.", |
| 30 | + default="current_draft_posts.md", |
| 31 | + ), |
28 | 32 | ):
|
29 |
| - """ |
30 |
| - Concatenate all draft posts into a single markdown file. |
31 |
| - Params |
32 |
| - "file_out": "The output file name for concatenated drafts. Defaults to 'concatenated_drafts.md'." |
33 |
| - "search_directory": "The directory to search for draft posts. Defaults to 'content/post'." |
34 |
| - "search_string": "The string to search for in the markdown files to identify drafts. Defaults to 'draft: true'." |
35 |
| - """ |
36 | 33 | check_project_root()
|
37 | 34 | concatenate_drafts(
|
38 | 35 | file_out=file_out,
|
39 |
| - search_directory=search_directory, |
40 |
| - search_string=search_string, |
| 36 | + search_directory="content/post", |
| 37 | + search_string="draft: true", |
41 | 38 | )
|
42 | 39 |
|
43 | 40 |
|
|
0 commit comments