ocurrent / ocurrent/ocluster

Add bash completion script and automate `.cap` file lookup for for ocluster-admin

Open
#244 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

good first issue
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-admint looks in particular location for the admin.cap file ("convention over configuration")
  • Add the auto-completion script to the installation recipe.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.