-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ft option #20
Ft option #20
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,11 @@ def convertMarkdown( | |
"--prefix", | ||
help="Can be used to make your markdown decks part of a single subdeck. Anki uses `::` to indicate sub decks. `markdown-decks::` could be used to make all generated decks part of a single root deck `markdown-decks`", | ||
), | ||
filetype: str = typer.Option( | ||
"md", | ||
"--ft", | ||
help="Can be use to specify the use of other filetypes. Specify just the fine extension, e.g., 'txt'", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change the help text to something like. "This option lets you specify which file extensions markdown-anki-decks will use when searching for files to convert into Anki decks. By default, it uses 'md' as the only file extension." |
||
), | ||
delete_cards: bool = typer.Option( | ||
False, | ||
"--delete", | ||
|
@@ -62,11 +67,12 @@ def convertMarkdown( | |
False, "--version", callback=version_callback, help="Show version information" | ||
), | ||
): | ||
|
||
"""Interface for the cli convert command.""" | ||
# iterate over the source directory | ||
for root, _, files in os.walk(input_dir): | ||
for file in files: | ||
if is_markdown_file(file): | ||
if is_correct_filetype(file, filetype): | ||
deck = parse_markdown( | ||
os.path.join(root, file), deck_title_prefix, cloze | ||
) | ||
|
@@ -242,10 +248,9 @@ def read_file(file): | |
|
||
|
||
# check if a file is a markdown file | ||
def is_markdown_file(file): | ||
"""Check if a file is a markdown file.""" | ||
# TODO(lukemurray): parameterize markdown extensions? | ||
return file.endswith(".md") | ||
def is_correct_filetype(file, filetype: str): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. change change the |
||
"""Check if a file has the correct extension.""" | ||
return file.endswith(f".{filetype}") | ||
|
||
|
||
def integer_hash(s: str): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change the name of this parameter to
extension
with a short option of--ext
? That would match the API exposed by other similar programs. For example, see eslint.Can we allow the user to pass multiple extensions instead of just a single string? See the page multiple cli options in the typer docs for instructions on how to do this. We would have to change the default value to
["md"]
and the type toOptional[List[str]]
.