Commit graph

17 commits

Author SHA1 Message Date
MidAutumnMoon
93eb8e9928 completions: zfs: fix for set subcmd 2022-06-15 20:48:08 +02:00
Mahmoud Al-Qudsi
6c81e2a627 zfs: Complete values for all properties
This patch adds completions for the values of properties, emitted once the
current token matches the name of a zfs property in full, for the various places
where such a property can be assigned.

e.g.

zfs set canmoun<TAB> continues to only provide "canmount" as a completion, but
zfs set canmount<TAB> will provide a list of all valid values for the property.

The existing code made an attempt to complete the values for the specific case
of `zfs set PROP=` but I could never get it to work for me under FreeBSD, so I
presume it was Linux-specific. This patch should be cross-platform and extends
the completions to anywhere where a property may be set.
2022-02-09 14:24:06 -06:00
Mahmoud Al-Qudsi
8d386a27f3 zfs completions: Factor out OpenZFS features and support
As of FreeBSD 13 (released April 2021), FreeBSD has rebased its zfs support on
top of the OpenZFS distribution previously used only/chiefly by Linux;
accordingly, it has gained support for some previously Linux-only completions.
This patch changes some completions previously predicated on a Linux ZFS
installation to the presence of an OpenZFS installation. Note that there
continue to be (and probably always will be) separate Linux-only and
FreeBSD-only completions (and not just when it comes to interacting with the
device subsystem, etc).
2022-02-08 14:17:00 -06:00
Mahmoud Al-Qudsi
6c8c8bf819 [zfs] Dynamically complete possible zfs property values
Use the man pages to dynamically generate possible completions for `zfs
set property=` payloads.

[ci skip] // Does that even work for GitHub actions?
2020-11-21 11:05:00 -06:00
Mahmoud Al-Qudsi
6bd4f52b0d [zfs] Optimize enumeration of snapshots
Only generate the list of snapshots when
a) the argument must be a snapshot and nothing else, or
b) the argument as typed contains a literal @, or
c) a snapshot is a valid completion and there is only one dataset
   matching the argument as entered.

Unfortunately, it seems the `zfs` command itself is extremely primitive
and doesn't support listing snapshots by dataset so when we need to
generate completions, we end up needing to enumerate all snapshots
(ever) across all datasets. I'd be very happy to be proven wrong, but I
think the only other way would be manually parse `zdb` output.

See #7472
2020-11-12 22:24:29 -06:00
Mahmoud Al-Qudsi
304649acc6 [zfs] Add completions for new dataset prefix
[ci skip]
2020-09-16 14:37:59 -05:00
Johannes Altmanninger
c54ee22c46 Refactor: remove unnecessary exports 2020-05-19 21:15:11 +02:00
Fabian Homborg
9367d4ff71 Reindent functions to remove useless quotes
This does not include checks/function.fish because that currently
includes a "; end" in a message that indent would remove, breaking the test.
2020-03-09 19:46:43 +01:00
Johannes Altmanninger
660182cfb3 completions/zfs: finish renaming from 05038fc8 2020-03-08 10:00:57 +01:00
Johannes Altmanninger
01d9e56bdd completions/zfs: fix syntax error from f507f4ad 2020-03-08 10:00:57 +01:00
Jason Nader
f507f4ad1e Ddon't use gettext fn in fish functions 2020-02-28 11:29:54 +01:00
Jason Nader
0b7bbb5654 cleanup completions: localise/erase vars where possible
[skip-ci]
2020-02-23 11:10:32 +01:00
Jason
965b142acd Move __fish_print_zfs_* into zfs completion script 2019-12-04 20:53:01 +01:00
Fabian Homborg
ce245704d7 Reformat completion scripts
These were excluded from style.fish
2019-05-05 12:53:09 +02:00
Fabian Homborg
05038fc865 completions/zfs: Stringify 2019-03-14 13:23:47 +01:00
Wilke Schwiedop
bd24e8662e fix 'sort | uniq' 2018-04-09 01:09:49 +02:00
David Guyot
dcf9ce6fc5 Added completions/translations for zfs and zpool 2017-12-21 16:39:06 +01:00