Skip to Content

PMIVerse CLI shortcut and Bash completion

What this provides

  • Friendly commands in your PATH:
  • restore-db → /srv/pmiverse/_pmiconfig/scripts/restore/restore_database.sh
  • Bash tab-completion for runnable commands under scripts/, including backup, laptop synchronization, restore, migration, repository updates, requirement collection, translation, testing, formatting, and integration.
  • Completes each command's supported options, including -h and --help.
  • Offers paths, registry aliases, database names, and fixed choices where applicable.
  • Restore suggests aliases until a positional target, --target, or --db selects the database, then suggests options. Option values retain their own alias, database, path, or fixed-choice suggestions.
  • Registers basenames, ./basename from a script's directory, absolute paths, scripts/..., and ./scripts/... forms.
  • Every runnable command accepts -h and --help before operational work. Commands without operational options now reject unknown arguments instead of ignoring them. The reserved policy checker documents its unimplemented status and returns failure when invoked for checks.

Sourced .bash libraries and migrate/fix_product_document_18.sql are not CLI entrypoints. Invoke commands directly for completion; interpreter-prefixed calls such as python3 script.py use the interpreter's own completion rules.

Files

  • Completion script: /srv/pmiverse/_pmiconfig/scripts/completion/pmiverse-completion.bash
  • Database-specific completion: /srv/pmiverse/_pmiregistry/scripts/completion/pmiverse-completion.bash. Shared completion loads this optional extension automatically when present; PMIREGISTRY_DIR selects an alternative registry checkout.
  • Installer: /srv/pmiverse/_pmiconfig/scripts/integration/install_cli_shortcuts.sh

Quick install (user mode)

/srv/pmiverse/_pmiconfig/scripts/integration/install_cli_shortcuts.sh --user
  • The symlink is created in ~/.local/bin (ensure it’s in your PATH)
  • Completion file is installed to ~/.bash_completion.d/pmiverse-completion.bash
  • ~/.bashrc is updated to load this completion file even if general bash-completion is already configured
  • Open a new terminal or source ~/.bashrc to activate completion

System-wide install (requires sudo)

sudo /srv/pmiverse/_pmiconfig/scripts/integration/install_cli_shortcuts.sh --system
  • The symlink goes to /usr/local/bin
  • Completion is installed to /etc/bash_completion.d/pmiverse-completion.bash
  • New shells will pick it up automatically when bash-completion is enabled

Dependencies

  • Bash with bash-completion package installed (standard on most distros). The completion script uses _init_completion from this package.

Example

  • Restore by alias with completion for demo and options:
restore-db demo --ne<TAB>

Notes

  • The installer is idempotent and can be re-run safely.
  • Registry values (aliases/db names) come from /srv/pmiverse/_pmiregistry/config/pmiverse.conf.
  • To activate the checkout's current definitions in an existing Bash shell: source /srv/pmiverse/_pmiconfig/scripts/completion/pmiverse-completion.bash. Ensure bash-completion is loaded first. Re-run the installer explicitly when you want to refresh its installed copy; source edits do not deploy it.
  • Reloading explicitly refreshes ./basename registrations, such as ./create_database.py. An older handler registered for that exact spelling otherwise takes precedence over Bash's fallback to the basename handler. After reloading, complete -p ./create_database.py should name _pmiverse_create_database_complete. Type ./create_database.py -- and press Tab without adding a space after the two hyphens.
  • tests/test_script_cli.py checks the complete command inventory, help safety, option coverage, value suggestions, path registrations, and user installation. Help probes run with read-only host files, hidden configuration, isolated networking, and an allowlist of harmless executables through Bubblewrap.