fish plugin: Assign the default output path to the option instead of using None

This commit is contained in:
Jaime Marquínez Ferrándiz 2022-02-16 21:42:08 +01:00
parent b46b4d2045
commit fedb8b0b8f

View file

@ -84,7 +84,7 @@ class FishPlugin(BeetsPlugin):
cmd.parser.add_option( cmd.parser.add_option(
'-o', '-o',
'--output', '--output',
default=None, default='~/.config/fish/completions/beet.fish',
help='save the script to a specific file, by default it will be' help='save the script to a specific file, by default it will be'
'saved to ~/.config/fish/completions') 'saved to ~/.config/fish/completions')
return [cmd] return [cmd]
@ -96,13 +96,8 @@ class FishPlugin(BeetsPlugin):
# Make a giant string of all the above, formatted in a way that # Make a giant string of all the above, formatted in a way that
# allows Fish to do tab completion for the `beet` command. # allows Fish to do tab completion for the `beet` command.
completion_file_path = opts.output completion_file_path = os.path.expanduser(opts.output)
if completion_file_path is not None: completion_dir = os.path.dirname(completion_file_path)
completion_dir = os.path.dirname(completion_file_path)
else:
home_dir = os.path.expanduser("~")
completion_dir = os.path.join(home_dir, '.config/fish/completions')
completion_file_path = os.path.join(completion_dir, 'beet.fish')
if completion_dir != '': if completion_dir != '':
os.makedirs(completion_dir, exist_ok=True) os.makedirs(completion_dir, exist_ok=True)