mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-11 17:18:30 +02:00
Merge 1b8ad23a19
into f2e207de85
This commit is contained in:
commit
41e7a9bb84
1 changed files with 21 additions and 9 deletions
20
jrnl.py
20
jrnl.py
|
@ -358,6 +358,14 @@ if __name__ == "__main__":
|
||||||
with open(CONFIG_PATH) as f:
|
with open(CONFIG_PATH) as f:
|
||||||
config = json.load(f)
|
config = json.load(f)
|
||||||
|
|
||||||
|
# update config file with settings introduced in a later version
|
||||||
|
missing_keys = set(default_config).difference(config)
|
||||||
|
if missing_keys:
|
||||||
|
for key in missing_keys:
|
||||||
|
config[key] = default_config[key]
|
||||||
|
with open(CONFIG_PATH, 'w') as f:
|
||||||
|
json.dump(config, f, indent=2)
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
composing = parser.add_argument_group('Composing', 'Will make an entry out of whatever follows as arguments')
|
composing = parser.add_argument_group('Composing', 'Will make an entry out of whatever follows as arguments')
|
||||||
composing.add_argument('-date', dest='date', help='Date, e.g. "yesterday at 5pm"')
|
composing.add_argument('-date', dest='date', help='Date, e.g. "yesterday at 5pm"')
|
||||||
|
@ -396,12 +404,16 @@ if __name__ == "__main__":
|
||||||
if config['editor']:
|
if config['editor']:
|
||||||
tmpfile = os.path.join(tempfile.gettempdir(), "jrnl")
|
tmpfile = os.path.join(tempfile.gettempdir(), "jrnl")
|
||||||
subprocess.call(config['editor'].split() + [tmpfile])
|
subprocess.call(config['editor'].split() + [tmpfile])
|
||||||
with open(tmpfile) as f:
|
if os.path.exists(tmpfile):
|
||||||
raw = f.read()
|
with open(tmpfile) as f:
|
||||||
os.remove(tmpfile)
|
raw = f.read()
|
||||||
|
os.remove(tmpfile)
|
||||||
|
else:
|
||||||
|
print('nothing saved to file')
|
||||||
|
raw = ''
|
||||||
else:
|
else:
|
||||||
raw = raw_input("Compose Entry: ")
|
raw = raw_input("Compose Entry: ")
|
||||||
|
|
||||||
if raw:
|
if raw:
|
||||||
args.text = [raw]
|
args.text = [raw]
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Reference in a new issue