Hello!
I’m trying to add completions to my Go CLI application packaged as a Snap.
The completer fails, because it cannot access the application itself.
But it needs to run the application, because the completion is implemented by calling “<app> __complete
”, so most of the completion logic just lives in the main application itself.
I’m using Cobra for the CLI framework (https://github.com/spf13/cobra), which is just implemented this way.
I’ve followed the guide Debugging tab completion, and found that it’s failing on the following:
$ snap run --command=complete klock.kubectl-klock 9 9 20 1 ' ' 'klock.kubectl-klock ' klock.kubectl-klock ''
# /...snip.../
+ __klock.kubectl-klock_debug '+++ klock.kubectl-klock __complete '\'''\''
/snap/klock/x1/bin/klock.kubectl-klock.completion.bash: line 58: klock.kubectl-klock: command not found'
+ [[ -n /dev/stderr ]]
+ echo '+++ klock.kubectl-klock __complete '\'''\''
/snap/klock/x1/bin/klock.kubectl-klock.completion.bash: line 58: klock.kubectl-klock: command not found'
+++ klock.kubectl-klock __complete ''
/snap/klock/x1/bin/klock.kubectl-klock.completion.bash: line 58: klock.kubectl-klock: command not found
Now, just switching the Snap’s confinement to classic
solves this issue. But would be nice to not need this.
The snap.yaml
file looks like so:
name: klock
version: 0.4.0-SNAPSHOT-f573ee2
summary: Kubectl plugin that watches resources
description: |
Kubectl plugin that watches resources and prints them in a human-readable manner.
Very similar to `kubectl get`, but with live updates.
base: core22
license: GPL-3.0-or-later
grade: stable
confinement: strict
architectures:
- amd64
apps:
kubectl-complete:
command: kubectl_complete-klock
aliases:
- kubectl_complete-klock
kubectl-klock:
command: kubectl-klock
aliases:
- kubectl-klock
completer: bin/klock.kubectl-klock.completion.bash
plugs:
- home
- network
Any ideas?