mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-17 19:48:31 +02:00
add --config (-c) option to show config path & contents
This commit is contained in:
parent
37e5fe9feb
commit
a05ebb21eb
2 changed files with 12 additions and 0 deletions
|
@ -24,6 +24,8 @@ def parse_args(args=None):
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('-v', '--version', dest='version', action="store_true", help="prints version information and exits")
|
parser.add_argument('-v', '--version', dest='version', action="store_true", help="prints version information and exits")
|
||||||
parser.add_argument('-ls', dest='ls', action="store_true", help="displays accessible journals")
|
parser.add_argument('-ls', dest='ls', action="store_true", help="displays accessible journals")
|
||||||
|
# yarko test:
|
||||||
|
parser.add_argument('-c', '--config', dest='conf', action="store_true", help="shows current config file and path")
|
||||||
|
|
||||||
composing = parser.add_argument_group('Composing', 'To write an entry simply write it on the command line, e.g. "jrnl yesterday at 1pm: Went to the gym."')
|
composing = parser.add_argument_group('Composing', 'To write an entry simply write it on the command line, e.g. "jrnl yesterday at 1pm: Went to the gym."')
|
||||||
composing.add_argument('text', metavar='', nargs="*")
|
composing.add_argument('text', metavar='', nargs="*")
|
||||||
|
@ -127,6 +129,10 @@ def run(manual_args=None):
|
||||||
print(util.py2encode(version_str))
|
print(util.py2encode(version_str))
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
if args.conf:
|
||||||
|
install.show_config()
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
config = install.install_jrnl()
|
config = install.install_jrnl()
|
||||||
|
|
||||||
if args.ls:
|
if args.ls:
|
||||||
|
|
|
@ -6,6 +6,7 @@ import readline
|
||||||
import glob
|
import glob
|
||||||
import getpass
|
import getpass
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import xdg.BaseDirectory
|
import xdg.BaseDirectory
|
||||||
from . import util
|
from . import util
|
||||||
import yaml
|
import yaml
|
||||||
|
@ -59,6 +60,11 @@ def upgrade_config(config):
|
||||||
save_config(config)
|
save_config(config)
|
||||||
print("[.jrnl_conf updated to newest version]")
|
print("[.jrnl_conf updated to newest version]")
|
||||||
|
|
||||||
|
def show_config():
|
||||||
|
with open(CONFIG_FILE_PATH) as f:
|
||||||
|
print "# ", CONFIG_FILE_PATH
|
||||||
|
sys.stdout.write(f.read())
|
||||||
|
|
||||||
|
|
||||||
def save_config(config):
|
def save_config(config):
|
||||||
with open(CONFIG_FILE_PATH, 'w') as f:
|
with open(CONFIG_FILE_PATH, 'w') as f:
|
||||||
|
|
Loading…
Add table
Reference in a new issue