Merge pull request #145 from zeronet-conservancy/help_config_rework
show help if exception is thrown early in startup
This commit is contained in:
commit
80c83fedaf
1 changed files with 12 additions and 2 deletions
12
src/main.py
12
src/main.py
|
@ -29,7 +29,8 @@ from Config import config
|
||||||
|
|
||||||
def load_config():
|
def load_config():
|
||||||
config.parse(silent=True) # Plugins need to access the configuration
|
config.parse(silent=True) # Plugins need to access the configuration
|
||||||
if not config.arguments: # Config parse failed, show the help screen and exit
|
if not config.arguments:
|
||||||
|
# Config parse failed completely, show the help screen and exit
|
||||||
config.parse()
|
config.parse()
|
||||||
|
|
||||||
load_config()
|
load_config()
|
||||||
|
@ -51,7 +52,16 @@ def init_dirs():
|
||||||
with open(users_json, "w") as f:
|
with open(users_json, "w") as f:
|
||||||
f.write("{}")
|
f.write("{}")
|
||||||
|
|
||||||
|
# TODO: GET RID OF TOP-LEVEL CODE!!!
|
||||||
|
|
||||||
|
try:
|
||||||
init_dirs()
|
init_dirs()
|
||||||
|
except:
|
||||||
|
import traceback as tb
|
||||||
|
print(tb.format_exc())
|
||||||
|
# at least make sure to print help if we're otherwise so helpless
|
||||||
|
config.parser.print_help()
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
if config.action == "main":
|
if config.action == "main":
|
||||||
from util import helper
|
from util import helper
|
||||||
|
|
Loading…
Reference in a new issue