mirror of
https://github.com/dtomlinson91/tembo.git
synced 2025-12-22 07:55:45 +00:00
60 lines
1.6 KiB
Python
60 lines
1.6 KiB
Python
import click
|
|
|
|
import tembo
|
|
from tembo.journal import pages
|
|
|
|
|
|
CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])
|
|
|
|
|
|
@click.group(context_settings=CONTEXT_SETTINGS, options_metavar="<options>")
|
|
def run():
|
|
"""
|
|
Tembo - an organiser for work notes.
|
|
"""
|
|
|
|
|
|
@click.command(options_metavar="<options>")
|
|
@click.argument("scope", metavar="<scope>")
|
|
@click.argument(
|
|
"inputs",
|
|
nargs=-1,
|
|
metavar="<inputs>",
|
|
)
|
|
@click.option("--dry-run", is_flag=True, default=False)
|
|
def new(scope, inputs, dry_run):
|
|
"""
|
|
Create a new note.
|
|
|
|
<scope> The name of the scope in the Tembo config.yml.
|
|
|
|
<inputs> Any input tokens needed in the Tembo config.yml.
|
|
|
|
Example: tembo new meeting my_presentation
|
|
"""
|
|
for user_scope in tembo.CONFIG.scopes:
|
|
if user_scope["name"] == scope:
|
|
scoped_page = pages.ScopedPageCreator().create_page(
|
|
base_path=str(tembo.CONFIG.base_path),
|
|
page_path=str(user_scope["path"]),
|
|
filename=str(user_scope["filename"]),
|
|
extension=str(user_scope["extension"]),
|
|
name=str(user_scope["name"]),
|
|
user_input=inputs,
|
|
template_filename=str(user_scope["template_filename"]),
|
|
)
|
|
scoped_page.save_to_disk(dry_run=dry_run)
|
|
tembo.logger.info("Saved %s to disk", scoped_page.path)
|
|
raise SystemExit(0)
|
|
tembo.logger.critical(
|
|
"No config.yml found in %s - exiting", tembo.CONFIG.config_path
|
|
)
|
|
raise SystemExit(1)
|
|
|
|
|
|
run.add_command(new)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
new(["scratchpad"], ())
|