Skip to content

Commit

Permalink
Add autocomplete for bash (kafka-ops#500)
Browse files Browse the repository at this point in the history
Co-authored-by: Bernhard Hopfenmüller <[email protected]>
  • Loading branch information
Fobhep and Bernhard Hopfenmüller authored Jul 29, 2022
1 parent 1e4aa03 commit 61fee75
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 5 deletions.
23 changes: 23 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,17 @@
</source>
</sources>
</mapping>
<mapping>
<directory>/usr/local/julie-ops/bin</directory>
<filemode>644</filemode>
<username>julie-kafka</username>
<groupname>julie-kafka</groupname>
<sources>
<source>
<location>src/main/scripts/julie-ops-complete.sh</location>
</source>
</sources>
</mapping>
<mapping>
<directory>/usr/local/julie-ops/conf</directory>
<configuration>true</configuration>
Expand Down Expand Up @@ -382,6 +393,18 @@
</mapper>
</data>

<data>
<src>${basedir}/src/main/scripts/julie-ops-complete.sh</src>
<type>file</type>
<mapper>
<type>perm</type>
<prefix>/usr/local/julie-ops/bin</prefix>
<user>julie-kafka</user>
<group>julie-kafka</group>
<filemode>644</filemode>
</mapper>
</data>

<data>
<src>${basedir}/src/main/conf</src>
<type>directory</type>
Expand Down
3 changes: 2 additions & 1 deletion src/deb/control/postinst
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash

ln -s /usr/local/julie-ops/bin/julie-ops-cli.sh /usr/bin/julie-ops
chown -R julie-kafka:julie-kafka /usr/local/julie-ops
ln -s /usr/local/julie-ops/bin/julie-ops-complete.sh /etc/bash_completion.d/julie-ops-complete
chown -R julie-kafka:julie-kafka /usr/local/julie-ops
3 changes: 2 additions & 1 deletion src/deb/control/prerm
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

rm -rf /usr/local/julie-ops/
unlink /usr/bin/julie-ops
unlink /etc/bash_completion.d/julie-ops-complete
userdel -f julie-kafka

if grep -q -E "^julie-kafka:" /etc/group;
then
groupdel julie-kafka
fi
fi
12 changes: 12 additions & 0 deletions src/main/scripts/julie-ops-complete.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail

function __julie-ops () {
local base_ops="--brokers|--clientConfig|--dryRun|--help|--overridingClientConfig|--plans|--quite|--topology|--validate|--version"
local cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=($(IFS='|' compgen -S ' ' -W "$base_ops" -- $cur ) )
}

complete -A alias -F __julie-ops julie-ops
5 changes: 4 additions & 1 deletion src/main/scripts/postinstall.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env bash

ln -s /usr/local/julie-ops/bin/julie-ops-cli.sh /usr/bin/julie-ops
chown julie-kafka.julie-kafka /usr/local/julie-ops/bin/julie-ops-cli.sh
ln -s /usr/local/julie-ops/bin/julie-ops-complete.sh /etc/bash_completion.d/julie-ops-complete

chown julie-kafka.julie-kafka /usr/local/julie-ops/bin/julie-ops-cli.sh
chown julie-kafka.julie-kafka /usr/local/julie-ops/bin/julie-ops-complete.sh
2 changes: 1 addition & 1 deletion src/main/scripts/preinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ type -P java &> /dev/null || { echo "java not found"; exit 1; }
verify_java_version_min_11
exit_code=$?

exit $exit_code
exit $exit_code
4 changes: 3 additions & 1 deletion src/main/scripts/remove.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

rm -rf /usr/local/julie-ops/
unlink /usr/bin/julie-ops
unlink /etc/bash_completion.d/julie-ops-complete

userdel -f julie-kafka

if grep -q -E "^julie-kafka:" /etc/group;
then
groupdel julie-kafka
fi
fi

0 comments on commit 61fee75

Please sign in to comment.