#compdef _sbctl sbctl


function _sbctl {
  local -a commands

  _arguments -C \
    "1: :->cmnds" \
    "*::arg:->args"

  case $state in
  cmnds)
    commands=(
      "bundle:Bundle the needed files for an EFI stub image"
      "completion:"
      "create-keys:Create a set of secure boot signing keys"
      "enroll-keys:Enroll the current keys to EFI"
      "generate-bundles:Generate all EFI stub bundles"
      "help:Help about any command"
      "list-bundles:List stored bundles"
      "list-files:List enrolled files"
      "remove-bundle:Remove bundle from database"
      "remove-file:Remove file from database"
      "sign:Sign a file with secure boot keys"
      "sign-all:Sign all enrolled files with secure boot keys"
      "status:Show current boot status"
      "verify:Find and check if files in the ESP are signed or not"
    )
    _describe "command" commands
    ;;
  esac

  case "$words[1]" in
  bundle)
    _sbctl_bundle
    ;;
  completion)
    _sbctl_completion
    ;;
  create-keys)
    _sbctl_create-keys
    ;;
  enroll-keys)
    _sbctl_enroll-keys
    ;;
  generate-bundles)
    _sbctl_generate-bundles
    ;;
  help)
    _sbctl_help
    ;;
  list-bundles)
    _sbctl_list-bundles
    ;;
  list-files)
    _sbctl_list-files
    ;;
  remove-bundle)
    _sbctl_remove-bundle
    ;;
  remove-file)
    _sbctl_remove-file
    ;;
  sign)
    _sbctl_sign
    ;;
  sign-all)
    _sbctl_sign-all
    ;;
  status)
    _sbctl_status
    ;;
  verify)
    _sbctl_verify
    ;;
  esac
}

function _sbctl_bundle {
  _arguments \
    '(-a --amducode)'{-a,--amducode}'[AMD microcode location]:' \
    '(-c --cmdline)'{-c,--cmdline}'[Cmdline location]:' \
    '(-e --efi-stub)'{-e,--efi-stub}'[EFI Stub location]:' \
    '(-p --esp)'{-p,--esp}'[ESP location]:' \
    '(-f --initramfs)'{-f,--initramfs}'[Initramfs location]:' \
    '(-i --intelucode)'{-i,--intelucode}'[Intel microcode location]:' \
    '(-k --kernel-img)'{-k,--kernel-img}'[Kernel image location]:' \
    '(-o --os-release)'{-o,--os-release}'[OS Release file location]:' \
    '(-s --save)'{-s,--save}'[save bundle to the database]' \
    '(-l --splash-img)'{-l,--splash-img}'[Boot splash image location]:'
}


function _sbctl_completion {
  local -a commands

  _arguments -C \
    "1: :->cmnds" \
    "*::arg:->args"

  case $state in
  cmnds)
    commands=(
    )
    _describe "command" commands
    ;;
  esac

  case "$words[1]" in
  esac
}

function _sbctl_create-keys {
  _arguments
}

function _sbctl_enroll-keys {
  _arguments
}

function _sbctl_generate-bundles {
  _arguments \
    '(-s --sign)'{-s,--sign}'[Sign all the generated bundles]'
}

function _sbctl_help {
  _arguments
}

function _sbctl_list-bundles {
  _arguments
}

function _sbctl_list-files {
  _arguments
}

function _sbctl_remove-bundle {
  _arguments
}

function _sbctl_remove-file {
  _arguments
}

function _sbctl_sign {
  _arguments \
    '(-o --output)'{-o,--output}'[output filename. Default replaces the file]:' \
    '(-s --save)'{-s,--save}'[save file to the database]'
}

function _sbctl_sign-all {
  _arguments \
    '(-g --generate)'{-g,--generate}'[run all generate-* sub-commands before signing]'
}

function _sbctl_status {
  _arguments
}

function _sbctl_verify {
  _arguments
}

(B[m