Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support tab-completion for bash and other shells #34

Open
hirak99 opened this issue May 17, 2024 · 1 comment
Open

Support tab-completion for bash and other shells #34

hirak99 opened this issue May 17, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@hirak99
Copy link
Owner

hirak99 commented May 17, 2024

No description provided.

@hirak99 hirak99 added the enhancement New feature or request label May 17, 2024
@SJFCS
Copy link

SJFCS commented Oct 3, 2024

zsh can use this

# _yabsnap.zsh
# This function provides tab completion for the yabsnap command.

_yabsnap() {
  local -a commands
  commands=(
    'list:List all managed snaps'
    'list-json:Machine readable list of all managed snaps'
    'create:Create new snapshots'
    'create-config:Bootstrap a config for new filesystem to snapshot'
    'delete:Delete a snapshot created by yabsnap'
    'rollback-gen:Generate script to rollback one or more snaps'
  )

  local -a options
  options=(
    '-h[Show help message]'
    '--help[Show help message]'
    '--sync[Wait for btrfs to sync for any delete operations]'
    '--config-file[Specify a config file to use]'
    '--source[Restrict to config with this source path]'
    '--dry-run[Disable all snapshot creation and deletion]'
    '--verbose[Sets log-level to INFO]'
  )

  # Complete commands
  if [[ $words[1] == "yabsnap" ]]; then
    _describe -t commands 'yabsnap command' commands
    return
  fi

  # Complete options for the commands
  if [[ $words[1] == "yabsnap" && $words[2] ]]; then
    _describe -t options 'yabsnap option' options
  fi
}

# Register the completion function
compdef _yabsnap yabsnap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants