Add bash completion script and automate `.cap` file lookup for for ocluster-admin
Nobody has claimed this yet.
- Dominant language
- OCaml
- Stars
- 42
- Forks
- 20
- PR merge metrics
- No merged PRs in 30d
Description
@mtelvers has a nice setup to streamline the use of the ocluster-admin. As a low priority way to improve operator quality of life and achieve some "documentation by automation" it could be cool to incorporate parts of these into the CLI and installation procedure.
But in the meantime, I'll just include the scripts her shared with me here, as this at least makes them available for others who may find them useful:
To avoid having to supply the path to an admin.cap wile, you can make a runner script like /usr/local/bin/ci3-admin
#!/bin/bash
ocluster-admin -c ~/.config/ocluster/admin.cap "$@"
Then get bash completions with this script added to, e.g., /etc/bash_completion.d/ci3-admin
#/usr/bin/env bash
_ci3-admin_completions()
{
WORDS=()
for value in "${COMP_WORDS[@]}"; do
[[ $value != --* ]] && WORDS+=($value)
done
if [ "${#WORDS[@]}" == "2" ]; then
COMPREPLY=($(compgen -W "$(ci3-admin 2>&1 | head -1 | grep -Po "'\K[^', .]*")" -- "${WORDS[1]}"))
return
fi
if [ "${#WORDS[@]}" == "3" ]; then
case ${WORDS[1]} in
show|pause|unpause|exec|forget|set-rate|update)
COMPREPLY=($(compgen -W "$(ci3-admin show)" -- "${WORDS[2]}"))
;;
esac
return
fi
if [ "${#WORDS[@]}" == "4" ]; then
case ${WORDS[1]} in
pause|unpause|forget|update)
COMPREPLY=($(compgen -W "$(ci3-admin show ${WORDS[2]} --terse)" -- "${WORDS[3]}"))
;;
esac
return
fi
}
complete -F _ci3-admin_completions ci3-admin
Including this in the installation and CLI might mean:
- Extend the CLI so that
ocluster-admintlooks in particular location for theadmin.capfile ("convention over configuration") - Add the auto-completion script to the installation recipe.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting the ocluster-admin CLI and the installation procedure; the issue provides runner and bash-completion scripts as behavioral examples but names no repository files. Done means the CLI can locate admin.cap by convention and the completion script is included by installation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bash, ocaml
- Domain
- cli, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100