mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-07-07 00:36:13 +02:00
Update more arg parsing options and handling
This commit is contained in:
parent
fb184c5f5e
commit
626a18a6ec
5 changed files with 240 additions and 181 deletions
|
@ -1,17 +1,3 @@
|
|||
def deprecated_cmd(old_cmd, new_cmd, callback, **kwargs):
|
||||
import sys
|
||||
from .util import RESET_COLOR, WARNING_COLOR
|
||||
|
||||
print(
|
||||
WARNING_COLOR,
|
||||
f"\nThe command {old_cmd} is deprecated and will be removed from jrnl soon.\n"
|
||||
f"Please use {new_cmd} instead.\n",
|
||||
RESET_COLOR,
|
||||
file=sys.stderr,
|
||||
)
|
||||
callback(**kwargs)
|
||||
|
||||
|
||||
def preconfig_diagnostic(_):
|
||||
import platform
|
||||
import sys
|
||||
|
@ -31,22 +17,7 @@ def preconfig_version(_):
|
|||
print(version_str)
|
||||
|
||||
|
||||
def preconfig_command(args):
|
||||
print("this is a pre-config command")
|
||||
|
||||
|
||||
def postconfig_list(config, **kwargs):
|
||||
from .util import list_journals
|
||||
|
||||
print(list_journals(config))
|
||||
|
||||
|
||||
def list_journals(config):
|
||||
from . import install
|
||||
|
||||
"""List the journals specified in the configuration file"""
|
||||
result = f"Journals defined in {install.CONFIG_FILE_PATH}\n"
|
||||
ml = min(max(len(k) for k in config["journals"]), 20)
|
||||
for journal, cfg in config["journals"].items():
|
||||
result += " * {:{}} -> {}\n".format(
|
||||
journal, ml, cfg["journal"] if isinstance(cfg, dict) else cfg
|
||||
)
|
||||
return result
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue