From 4feda666083dc87b0e91493d208e099b4f8b6ad3 Mon Sep 17 00:00:00 2001 From: Micah Jerome Ellison Date: Sat, 13 Jun 2020 14:21:49 -0700 Subject: [PATCH] Add diagnostic argument #727 --- features/core.feature | 5 +++++ jrnl/cli.py | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/features/core.feature b/features/core.feature index f9b335e6e..5bec4e956 100644 --- a/features/core.feature +++ b/features/core.feature @@ -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" diff --git a/jrnl/cli.py b/jrnl/cli.py index f6bb3b89d..8e5833910 100644 --- a/jrnl/cli.py +++ b/jrnl/cli.py @@ -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: