ask for a destination if instantiated without a filename #15

Merged
tux merged 3 commits from ask-for-destination into master 2020-07-28 11:14:49 +02:00
Showing only changes of commit 43c2cffc83 - Show all commits

View file

@ -4,7 +4,7 @@
import npyscreen
import json
import datetime
from sys import argv
import sys
import pathlib
from base_data_model import base_data_model
@ -59,18 +59,21 @@ class FormApp(npyscreen.NPSAppManaged):
def main(*_args):
if len(argv) > 1:
filename = argv[1]
if len(sys.argv) > 1:
file_path = pathlib.Path(sys.argv[1])
if not file_path.exists():
print("Trying to open nonexistent file. Aborting.")
sys.exit(0)
else:
filename = pathlib.Path(pathlib.Path(__file__).absolute().parent, 'example.json')
file_path = pathlib.Path(pathlib.Path(__file__).absolute().parent, 'example.json')
app = FormApp(filename)
app = FormApp(file_path)
try:
app.run()
except Exception as e:
print(e)
return 0
sys.exit(0)
if app.data_has_changed():
out_data = app.get_data_from_form()