frankenphp icon indicating copy to clipboard operation
frankenphp copied to clipboard

feat(docs): add autocompletion docs

Open alexandre-daubois opened this issue 1 month ago • 16 comments

alexandre-daubois avatar Nov 21 '25 13:11 alexandre-daubois

Huh neat, I had no idea this was a thing.

henderkes avatar Nov 21 '25 14:11 henderkes

Hmm, bash autocompletion isn't working for me. Neither on RHEL 10 nor on Trixie. I checked with caddy completion bash and that works.

henderkes avatar Nov 23 '25 10:11 henderkes

https://github.com/alexandre-daubois/frankenphp/pull/4

henderkes avatar Nov 23 '25 10:11 henderkes

That's strange, I'm not sure how I made it work then 🤔 This is curious, I need to investigate this.

sed would indeed do the job, but I don't know how much I find it too hacky to put it in the docs then

And thanks for the PR on my fork, I'll have a deeper look tomorrow!

alexandre-daubois avatar Nov 23 '25 15:11 alexandre-daubois

Perhaps there's something like the CustomVersion parameter that we need to set to update the binary name? @mholt would likely know, I've googled without much luck.

henderkes avatar Nov 23 '25 15:11 henderkes

@henderkes Letsee... I didn't implement that, I think we're using Cobra for completion generation. I dunno if that gives you enough of a hint, I'll keep looking for a few minutes before I have to move onto something else. But I think @Mohammed90 might have an idea.

mholt avatar Nov 24 '25 19:11 mholt

Oh, did you run the completion command with caddy? If so, try running as frankenphp... I have no idea if that would make a difference, but...

mholt avatar Nov 24 '25 19:11 mholt

Oh, did you run the completion command with caddy? If so, try running as frankenphp... I have no idea if that would make a difference, but...

It's running with frankenphp completion bash, but spits out caddy regardless.

henderkes avatar Nov 24 '25 20:11 henderkes

@henderkes I might have found it:

https://github.com/caddyserver/caddy/blob/67a9e0657e60df8c78510065e8977d86ee17d01c/cmd/cobra.go#L13

If you change that line, does it have the expected results for you?

mholt avatar Nov 24 '25 22:11 mholt

I'll figure out how to make xcaddy build with a local caddy source tree and report back... hopefully tomorrow. If not, it will have to wait until next week after SymfonyCon. Thank you for your input!

henderkes avatar Nov 24 '25 22:11 henderkes

xcaddy build --with github.com/caddyserver/caddy/v2=../caddy or something like that, should do the trick.

I am a bit busy atm or I'd just check for you.

If changing that variable does work (again, I don't know the internals of Cobra, so it's a guess, but probably a good one), we can find a way to export that or somehow accommodate your build process.

mholt avatar Nov 24 '25 22:11 mholt

Matt is right, Cobra takes the name of the root command, which in our case is Caddy.

https://github.com/spf13/cobra/blob/fc81d2003469e2a5c440306d04a6d82a54065979/completions.go#L824

I'm not sure how we could modularize it, from the top of my head.

mohammed90 avatar Nov 25 '25 04:11 mohammed90

We could probably export it to a package-level variable, that can be changed at init-time... or some sort of const that gets changed during a build step, I dunno.

mholt avatar Nov 25 '25 05:11 mholt

Perhaps similar to how we can overwrite the version output?

henderkes avatar Nov 26 '25 13:11 henderkes

Yeah, kind of like the caddy.CustomVersion variable.

mholt avatar Dec 04 '25 17:12 mholt

Let's convert this one to draft, I'll have a deeper look whenever I have some bandwidth. Thanks for the hints!

alexandre-daubois avatar Dec 04 '25 18:12 alexandre-daubois