Skip to content

Add shell completion scripts for bash and zsh #35

@parfenovvs

Description

@parfenovvs

Summary

Generate and install shell completion scripts for bash and zsh to improve command-line user experience.

Features

Completion Support

  • Command completion (connect, disconnect, status, etc.)
  • Server name completion from cached server list
  • Country and city code completion
  • Flag and option completion
  • Context-aware suggestions

Installation Methods

# Generate completion scripts
mbvpn completion bash > mbvpn-completion.bash
mbvpn completion zsh > mbvpn-completion.zsh

# Install system-wide (requires admin)
mbvpn completion install

# Install for current user
mbvpn completion install --user

Example Completions

$ mbvpn co<TAB>
connect   countries

$ mbvpn connect us-<TAB>
us-east-01    us-east-02    us-west-01    us-west-02

$ mbvpn connect --<TAB>
--auto-reconnect    --kill-switch    --help

Implementation Details

  • Use Cobra's built-in completion support
  • Dynamic server completion from ~/.config/mbvpn/servers.json
  • Completion caching for performance
  • Support for both bash and zsh shells

Integration with Package Managers

  • Include completion files in deb/rpm packages
  • Install to standard locations:
    • Bash: /etc/bash_completion.d/mbvpn
    • Zsh: /usr/share/zsh/site-functions/_mbvpn

Files to Create

  • cmd/completion.go - Completion command implementation
  • scripts/install-completion.sh - Installation helper
  • Update installation documentation

Priority

🎯 Priority 1 (1-2 weeks)

Labels

  • enhancement
  • priority-1
  • user-experience
  • developer-experience

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions