Add diagnostic argument #727 (#984)

This commit is contained in:
Micah Jerome Ellison 2020-06-20 11:18:53 -07:00 committed by GitHub
parent 4238ca57de
commit 28093894ad
2 changed files with 22 additions and 0 deletions

View file

@ -130,3 +130,8 @@ Feature: Basic reading and writing to a journal
and we change directory to "features"
and we run "jrnl -n 1"
Then the output should contain "hello world"
Scenario: --diagnostic runs without exceptions
When we run "jrnl --diagnostic"
Then the output should contain "jrnl"
And the output should contain "Python"

View file

@ -21,6 +21,7 @@
import argparse
import logging
import platform
import re
import sys
@ -43,6 +44,14 @@ def parse_args(args=None):
action="store_true",
help="prints version information and exits",
)
parser.add_argument(
"--diagnostic",
dest="diagnostic",
action="store_true",
help="outputs diagnostic information and exits",
)
parser.add_argument(
"-ls", dest="ls", action="store_true", help="displays accessible journals"
)
@ -315,6 +324,14 @@ def run(manual_args=None):
print(version_str)
sys.exit(0)
if args.diagnostic:
print(
f"jrnl: {jrnl.__version__}\n"
f"Python: {sys.version}\n"
f"OS: {platform.system()} {platform.release()}"
)
sys.exit(0)
try:
config = install.load_or_install_jrnl()
except UserAbort as err: