feat: add version subcommand
This commit is contained in:
parent
af8b9b7c52
commit
8267ec6644
4 changed files with 31 additions and 18 deletions
1
halig/__version__.py
Normal file
1
halig/__version__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
__version__ = "0.1.8"
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
COMMANDS_NOTEBOOKS_HELP = "List all notebooks and notes, tree-style"
|
||||
COMMANDS_EDIT_HELP = "Edit or add a note into a notebook"
|
||||
COMMANDS_SHOW_HELP = "Show a note's contents"
|
||||
COMMANDS_VERSION = "Show halig's version"
|
||||
|
||||
# OPTIONS
|
||||
OPTION_CONFIG_HELP = "Configuration file. Must be YAML and schema compatible"
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ from halig.commands.notebooks import NotebooksCommand
|
|||
from halig.commands.show import ShowCommand
|
||||
from halig.settings import load_from_file
|
||||
from halig.utils import capture
|
||||
from halig.__version__ import __version__
|
||||
from rich import print
|
||||
|
||||
app = Typer(pretty_exceptions_enable=False, pretty_exceptions_show_locals=False)
|
||||
|
||||
|
|
@ -19,13 +21,13 @@ config_option = Option(None, "--config", "-c", help=literals.OPTION_CONFIG_HELP)
|
|||
@app.command(help=literals.COMMANDS_NOTEBOOKS_HELP)
|
||||
@capture
|
||||
def notebooks(
|
||||
level: int = Option( # noqa: B008
|
||||
-1,
|
||||
"--level",
|
||||
"-l",
|
||||
help=literals.OPTION_LEVEL_HELP,
|
||||
),
|
||||
config: Optional[Path] = config_option, # noqa: UP007
|
||||
level: int = Option( # noqa: B008
|
||||
-1,
|
||||
"--level",
|
||||
"-l",
|
||||
help=literals.OPTION_LEVEL_HELP,
|
||||
),
|
||||
config: Optional[Path] = config_option, # noqa: UP007
|
||||
):
|
||||
if level < 0:
|
||||
level = float("inf") # type: ignore[assignment]
|
||||
|
|
@ -37,11 +39,11 @@ def notebooks(
|
|||
@app.command(help=literals.COMMANDS_EDIT_HELP)
|
||||
@capture
|
||||
def edit(
|
||||
note: Path = Argument( # noqa: B008
|
||||
...,
|
||||
help=literals.ARGUMENT_EDIT_NOTE_HELP,
|
||||
),
|
||||
config: Optional[Path] = config_option, # noqa: UP007
|
||||
note: Path = Argument( # noqa: B008
|
||||
...,
|
||||
help=literals.ARGUMENT_EDIT_NOTE_HELP,
|
||||
),
|
||||
config: Optional[Path] = config_option, # noqa: UP007
|
||||
):
|
||||
settings = load_from_file(config)
|
||||
command = EditCommand(settings=settings, note_path=note)
|
||||
|
|
@ -51,16 +53,22 @@ def edit(
|
|||
@app.command(help=literals.COMMANDS_SHOW_HELP)
|
||||
@capture
|
||||
def show(
|
||||
note: Path = Argument( # noqa: B008
|
||||
...,
|
||||
help=literals.ARGUMENT_SHOW_NOTE_HELP,
|
||||
),
|
||||
config: Optional[Path] = config_option, # noqa: UP007
|
||||
note: Path = Argument( # noqa: B008
|
||||
...,
|
||||
help=literals.ARGUMENT_SHOW_NOTE_HELP,
|
||||
),
|
||||
config: Optional[Path] = config_option, # noqa: UP007
|
||||
):
|
||||
settings = load_from_file(config)
|
||||
command = ShowCommand(settings=settings, note_path=note)
|
||||
command.run()
|
||||
|
||||
|
||||
@app.command(help=literals.COMMANDS_VERSION)
|
||||
@capture
|
||||
def version():
|
||||
print(__version__)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app()
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ dependencies = [
|
|||
"pendulum>=2.1.2",
|
||||
]
|
||||
name = "halig"
|
||||
version = "0.1.7"
|
||||
dynamic = ["version"]
|
||||
description = "age-encrypted, file-based, note-taking CLI app"
|
||||
readme = "README.md"
|
||||
keywords = ["cli", "notes", "age", "rage", "encryption", "notebook"]
|
||||
|
|
@ -36,6 +36,9 @@ Repository = "https://git.roboces.dev/catalin/halig"
|
|||
Documentation = "https://git.roboces.dev/catalin/halig"
|
||||
Changelog = "https://git.roboces.dev/catalin/halig"
|
||||
|
||||
[tool.pdm]
|
||||
version = { source = "file", path = "halig/__version__.py" }
|
||||
|
||||
[tool.pdm.build]
|
||||
excludes = ["**/.pytest_cache/**"]
|
||||
includes = []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue