mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 16:42:42 +01:00
fish plugin: Add --output option
This commit is contained in:
parent
d0a5f812fd
commit
8e5156d01c
3 changed files with 25 additions and 8 deletions
|
|
@ -81,6 +81,11 @@ class FishPlugin(BeetsPlugin):
|
|||
choices=library.Item.all_keys() +
|
||||
library.Album.all_keys(),
|
||||
help='include specified field *values* in completions')
|
||||
cmd.parser.add_option(
|
||||
'-o',
|
||||
'--output',
|
||||
default=None,
|
||||
help='save the script to a specific file, by default it will be saved to ~/.config/fish/completions')
|
||||
return [cmd]
|
||||
|
||||
def run(self, lib, opts, args):
|
||||
|
|
@ -89,14 +94,22 @@ class FishPlugin(BeetsPlugin):
|
|||
# If specified, also collect the values for these fields.
|
||||
# Make a giant string of all the above, formatted in a way that
|
||||
# allows Fish to do tab completion for the `beet` command.
|
||||
|
||||
completion_file_path = opts.output
|
||||
if completion_file_path is not None:
|
||||
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 != '':
|
||||
try:
|
||||
os.makedirs(completion_dir)
|
||||
except OSError:
|
||||
if not os.path.isdir(completion_dir):
|
||||
raise
|
||||
completion_file_path = os.path.join(completion_dir, 'beet.fish')
|
||||
|
||||
nobasicfields = opts.noFields # Do not complete for album/track fields
|
||||
extravalues = opts.extravalues # e.g., Also complete artists names
|
||||
beetcmds = sorted(
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ Other new things:
|
|||
|
||||
* :doc:`/plugins/limit`: Limit query results to head or tail (``lslimit``
|
||||
command only)
|
||||
* :doc:`/plugins/fish`: Add ``--output`` option.
|
||||
|
||||
1.6.0 (November 27, 2021)
|
||||
-------------------------
|
||||
|
|
|
|||
|
|
@ -50,3 +50,6 @@ with care when specified fields contain a large number of values. Libraries with
|
|||
for example, very large numbers of genres/artists may result in higher memory
|
||||
utilization, completion latency, et cetera. This option is not meant to replace
|
||||
database queries altogether.
|
||||
|
||||
By default the completion file will be generated at ``~/.config/fish/completions/``,
|
||||
if you want to save it somewhere else you can use the ``-o`` or ``--output``.
|
||||
|
|
|
|||
Loading…
Reference in a new issue