mirror of
https://github.com/b-ryan/powerline-shell.git
synced 2026-09-10 07:26:28 -04:00
Improve manual config file option.
Instead of adding the result of --config-file (now -c --config) to the search path, avoid doing the search path when that argument is present. Return an error if the user specifies a --config file that doesn't exist.
This commit is contained in:
parent
a46154b9f8
commit
2f27bc2f90
|
|
@ -142,10 +142,10 @@ class Powerline(object):
|
|||
segment[3]))
|
||||
|
||||
|
||||
def find_config(default_location):
|
||||
def find_config():
|
||||
for location in [
|
||||
"powerline-shell.json",
|
||||
default_location,
|
||||
"~/.powerline-shell.json",
|
||||
os.path.join(os.environ.get("XDG_CONFIG_HOME", "~/.config"), "powerline-shell", "config.json"),
|
||||
]:
|
||||
full = os.path.expanduser(location)
|
||||
|
|
@ -188,8 +188,8 @@ def main():
|
|||
arg_parser = argparse.ArgumentParser()
|
||||
arg_parser.add_argument('--generate-config', action='store_true',
|
||||
help='Generate the default config and print it to stdout')
|
||||
arg_parser.add_argument('--config-file', action='store', default='~/.powerline-shell.json',
|
||||
help='Override config location')
|
||||
arg_parser.add_argument('-c', '--config', action='store', default=None,
|
||||
help='Override default config file location')
|
||||
arg_parser.add_argument('--shell', action='store', default='bash',
|
||||
help='Set this to your shell type',
|
||||
choices=['bash', 'tcsh', 'zsh', 'bare'])
|
||||
|
|
@ -201,7 +201,13 @@ def main():
|
|||
print(json.dumps(DEFAULT_CONFIG, indent=2))
|
||||
return 0
|
||||
|
||||
config_path = find_config(args.config_file)
|
||||
if args.config_file and not os.path.exists(os.path.expanduser(args.config_file)):
|
||||
print("Cannot find config file: {}".format(args.config_file), file=sys.stderr)
|
||||
return 1
|
||||
elif args.config_file:
|
||||
config_path = args.config_file
|
||||
else:
|
||||
config_path = find_config()
|
||||
if config_path:
|
||||
with open(config_path) as f:
|
||||
try:
|
||||
|
|
|
|||
Loading…
Reference in a new issue