Skip to content

Commit

Permalink
CLI completion fixes (latest-candidate) (canonical#633)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomponline authored Nov 25, 2024
2 parents 3134c81 + 6a90820 commit 87af004
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1529,12 +1529,14 @@ parts:
mkdir -p "${CRAFT_PART_INSTALL}/etc/bash_completion.d/"
# Snapd requires the unaliased command `lxd.lxc` to be supplied as the first command for completion to be detected
set_cmds='s/^\s*complete.*__start_lxc /&lxd.lxc /'
# When executed by Snapd, the COLUMNS shell value is unset, so use $(tput cols) instead
set_cols='s/COLUMNS/$(tput cols)/'
# When executed by snapd, the COLUMNS shell value is unset, so use $(tput cols) instead
set_cols='s/# $COLUMNS.*/COLUMN="$(tput cols)" \# store the current shell width./'
# When executed by snapd, the `compopt` support detection doesn't work so fake that it is always `builtin`
set_compopt='s|$(type -t compopt)|"builtin"|'
# Modify requestComp variable to use lxc based on context ($SNAP/bin/lxc in Snap environment)
set_request_comp='s|requestComp="${words\[0\]} __complete ${args\[\*\]}"|requestComp="/snap/lxd/current/bin/lxc __complete ${args[*]}"|'
# Generate completions script
"${CRAFT_PART_INSTALL}/bin/lxc" completion bash | sed -e "${set_cmds}" -e "${set_cols}" -e "${set_request_comp}" > "${CRAFT_PART_INSTALL}/etc/bash_completion.d/snap.lxd.lxc"
"${CRAFT_PART_INSTALL}/bin/lxc" completion bash | sed -e "${set_cmds}" -e "${set_cols}" -e "${set_compopt}" -e "${set_request_comp}" > "${CRAFT_PART_INSTALL}/etc/bash_completion.d/snap.lxd.lxc"
organize:
usr/bin/: bin/
usr/lib/: lib/
Expand Down

0 comments on commit 87af004

Please sign in to comment.