pacak / bpaf

Command line parser with applicative interface
Apache License 2.0
352 stars 17 forks source link

fish completions wont complete past subcommand #387

Closed ozwaldorf closed 1 month ago

ozwaldorf commented 1 month ago

On fish, the only completions present are for the subcommands, any other completions are blocked by the subcommand suggestions, even after putting a subcommand.

oz@onix ~/C/o/lutgen (main)> lutgen apply <TAB>
apply  (Apply a generated or provided Hald CLUT to images.)  palette                (Print palette names and colors)
generate           (Generate and save a Hald CLUT to disk.)  patch  (Generate a patch for colors inside text files.)

On zsh:

● lutgen apply <TAB>
directory
benches/   docs/      palettes/  result@    src/       target/
--dir                    -- Always save to a directory when there is only one input file.
--output=PATH            -- Path to write output to.
--palette=PALETTE        -- Builtin or custom palette to use.
--cache                  -- Cache generated LUT. No effect when using an external LUT.
--hald-clut=FILE         -- External Hald CLUT to use instead of generating one.
--lum=FACTOR             -- Factor to multiply luminocity values by. Effectively weights the interpolation to prefer
--level=2-16             -- Hald clut level to generate. A level of 16 stores a value for the entire sRGB color space.
--nearest=NEAREST        -- Number of nearest colors to consider when interpolating. 0 uses all available colors.
--preserve               -- Preserve the original image's luminocity values after interpolation.
--shape=SHAPE            -- Shape parameter for the default Gaussian RBF interpolation. Effectively creates more or
pacak commented 1 month ago

Hmm... Internals are the same for all the shells, the only difference is how completion info is collected from the shell and how results are rendered once they are known. Part responsible for collecting info from fish sits here:

https://github.com/pacak/bpaf/blob/216e56341851adb7bb6e82ff57b0c96b9b19a436/src/complete_run.rs#L33-L42

It is supposed to run the original binary with --bpaf-complete-rev=9, followed by all the arguments, followed by an empty argument if what we are trying to complete is a new word. Line 38 smells fishy. I guess it can use a bit of escaping?

pacak commented 1 month ago

Actually the fish stub is just wrong. Interestingly enough I made the change to make test to pass - and they pass just once per shell... Trying to fix.

pacak commented 1 month ago

Going back to revision 1 makes them look less fancy, but at least they work. Looking for a way to implement dynamic completions better. If all else fails - will go back and release a new version this later week.