feat: add --plain option to the show command in order to render notes as plaintext
This commit is contained in:
parent
fc81531f3c
commit
af9a6d82f4
14 changed files with 318 additions and 473 deletions
|
|
@ -1,5 +1,6 @@
|
|||
from pathlib import Path
|
||||
|
||||
from rich import print
|
||||
from rich.console import Console
|
||||
from rich.markdown import Markdown
|
||||
|
||||
|
|
@ -10,11 +11,12 @@ from halig.settings import Settings
|
|||
|
||||
|
||||
class ShowCommand(BaseCommand):
|
||||
def __init__(self, note_path: Path, settings: Settings):
|
||||
def __init__(self, note_path: Path, settings: Settings, plain: bool = False):
|
||||
super().__init__(settings)
|
||||
|
||||
self.note_path = self.settings.notebooks_root_path / note_path
|
||||
self.encryptor = Encryptor(self.settings)
|
||||
self.plain = plain
|
||||
self.console = Console()
|
||||
if self.note_path.is_dir():
|
||||
self.note_path /= f"{utils.now().date()}.age"
|
||||
|
|
@ -33,5 +35,9 @@ class ShowCommand(BaseCommand):
|
|||
return self.encryptor.decrypt(data).decode()
|
||||
|
||||
def run(self): # pragma: no cover
|
||||
md_contents = Markdown(self.decrypt())
|
||||
contents = self.decrypt()
|
||||
if self.plain:
|
||||
print(contents)
|
||||
return
|
||||
md_contents = Markdown(contents)
|
||||
self.console.print(md_contents)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue