| 68 | |
| 69 | class FishPlugin(BeetsPlugin): |
| 70 | def commands(self): |
| 71 | cmd = ui.Subcommand("fish", help="generate Fish shell tab completions") |
| 72 | cmd.func = self.run |
| 73 | cmd.parser.add_option( |
| 74 | "-f", |
| 75 | "--noFields", |
| 76 | action="store_true", |
| 77 | default=False, |
| 78 | help="omit album/track field completions", |
| 79 | ) |
| 80 | cmd.parser.add_option( |
| 81 | "-e", |
| 82 | "--extravalues", |
| 83 | action="append", |
| 84 | type="choice", |
| 85 | choices=list(library.Item.all_keys() | library.Album.all_keys()), |
| 86 | help="include specified field *values* in completions", |
| 87 | ) |
| 88 | cmd.parser.add_option( |
| 89 | "-o", |
| 90 | "--output", |
| 91 | default="~/.config/fish/completions/beet.fish", |
| 92 | help=( |
| 93 | "where to save the script. default: ~/.config/fish/completions" |
| 94 | ), |
| 95 | ) |
| 96 | return [cmd] |
| 97 | |
| 98 | def run(self, lib, opts, args): |
| 99 | # Gather the commands from Beets core and its plugins. |