All Downloads are FREE. Search and download functionalities are using the official Maven repository.

micronaut-cli.1.2.2.source-code.mn_completion Maven / Gradle / Ivy

There is a newer version: 2.0.0.M2
Show newest version
#!/usr/bin/env bash
#
# mn Bash Completion
# =======================
#
# Bash completion support for the `mn` command,
# generated by [picocli](http://picocli.info/) version 3.5.0.
#
# Installation
# ------------
#
# 1. Source all completion scripts in your .bash_profile
#
#   cd $YOUR_APP_HOME/bin
#   for f in $(find . -name "*_completion"); do line=". $(pwd)/$f"; grep "$line" ~/.bash_profile || echo "$line" >> ~/.bash_profile; done
#
# 2. Open a new bash console, and type `mn [TAB][TAB]`
#
# 1a. Alternatively, if you have [bash-completion](https://github.com/scop/bash-completion) installed:
#     Place this file in a `bash-completion.d` folder:
#
#   * /etc/bash-completion.d
#   * /usr/local/etc/bash-completion.d
#   * ~/bash-completion.d
#
# Documentation
# -------------
# The script is called by bash whenever [TAB] or [TAB][TAB] is pressed after
# 'mn (..)'. By reading entered command line parameters,
# it determines possible bash completions and writes them to the COMPREPLY variable.
# Bash then completes the user input if only one entry is listed in the variable or
# shows the options if more than one is listed in COMPREPLY.
#
# References
# ----------
# [1] http://stackoverflow.com/a/12495480/1440785
# [2] http://tiswww.case.edu/php/chet/bash/FAQ
# [3] https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html
# [4] http://zsh.sourceforge.net/Doc/Release/Options.html#index-COMPLETE_005fALIASES
# [5] https://stackoverflow.com/questions/17042057/bash-check-element-in-array-for-elements-in-another-array/17042655#17042655
# [6] https://www.gnu.org/software/bash/manual/html_node/Programmable-Completion.html#Programmable-Completion
#

if [ -n "$BASH_VERSION" ]; then
  # Enable programmable completion facilities when using bash (see [3])
  shopt -s progcomp
elif [ -n "$ZSH_VERSION" ]; then
  # Make alias a distinct command for completion purposes when using zsh (see [4])
  setopt COMPLETE_ALIASES
  alias compopt=complete
fi

# ArrContains takes two arguments, both of which are the name of arrays.
# It creates a temporary hash from lArr1 and then checks if all elements of lArr2
# are in the hashtable.
#
# Returns zero (no error) if all elements of the 2nd array are in the 1st array,
# otherwise returns 1 (error).
#
# Modified from [5]
function ArrContains() {
  local lArr1 lArr2
  declare -A tmp
  eval lArr1=("\"\${$1[@]}\"")
  eval lArr2=("\"\${$2[@]}\"")
  for i in "${lArr1[@]}";{ [ -n "$i" ] && ((++tmp[$i]));}
  for i in "${lArr2[@]}";{ [ -n "$i" ] && [ -z "${tmp[$i]}" ] && return 1;}
  return 0
}

# Bash completion entry point function.
# _complete_mn finds which commands and subcommands have been specified
# on the command line and delegates to the appropriate function
# to generate possible options and subcommands for the last specified subcommand.
function _complete_mn() {
  CMDS0=(create-app)
  CMDS1=(create-cli-app)
  CMDS2=(create-federation)
  CMDS3=(create-function)
  CMDS4=(create-profile)
  CMDS5=(help)
  CMDS6=(list-profiles)
  CMDS7=(profile-info)
  CMDS8=(!)
  CMDS9=(exit)
  CMDS10=(quit)

  ArrContains COMP_WORDS CMDS10 && { _picocli_mn_quit; return $?; }
  ArrContains COMP_WORDS CMDS9 && { _picocli_mn_exit; return $?; }
  ArrContains COMP_WORDS CMDS8 && { _picocli_mn_; return $?; }
  ArrContains COMP_WORDS CMDS7 && { _picocli_mn_profileinfo; return $?; }
  ArrContains COMP_WORDS CMDS6 && { _picocli_mn_listprofiles; return $?; }
  ArrContains COMP_WORDS CMDS5 && { _picocli_mn_help; return $?; }
  ArrContains COMP_WORDS CMDS4 && { _picocli_mn_createprofile; return $?; }
  ArrContains COMP_WORDS CMDS3 && { _picocli_mn_createfunction; return $?; }
  ArrContains COMP_WORDS CMDS2 && { _picocli_mn_createfederation; return $?; }
  ArrContains COMP_WORDS CMDS1 && { _picocli_mn_createcliapp; return $?; }
  ArrContains COMP_WORDS CMDS0 && { _picocli_mn_createapp; return $?; }

  # No subcommands were specified; generate completions for the top-level command.
  _picocli_mn; return $?;
}

# Generates completions for the options and subcommands of the `mn` command.
function _picocli_mn() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS="create-app create-cli-app create-federation create-function create-profile help list-profiles profile-info ! exit quit"
  FLAG_OPTS="-n --plain-output -x --stacktrace -v --verbose -h --help -V --version"
  ARG_OPTS=""

  COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS} ${COMMANDS}" -- ${CURR_WORD}) )
}

# Generates completions for the options and subcommands of the `create-app` subcommand.
function _picocli_mn_createapp() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-i --inplace -n --plain-output -x --stacktrace -v --verbose -h --help -V --version"
  ARG_OPTS="-l --lang -b --build -p --profile -f --features"
  LANG_OPTION_ARGS="java groovy kotlin" # SupportedLanguage values
  BUILDTOOL_OPTION_ARGS="gradle maven" # SupportedBuildTool values
  PROFILE_OPTION_ARGS="base cli federation function function-aws kafka profile service base cli federation function function-aws kafka profile service" # --profile values
  FEATURE_OPTION_ARGS="annotation-api cassandra config-consul discovery-consul discovery-eureka groovy hibernate-gorm hibernate-jpa http-client http-server java jdbc-dbcp jdbc-hikari jdbc-tomcat jrebel junit kafka kafka-streams kotlin kotlintest management micrometer micrometer-atlas micrometer-graphite micrometer-prometheus micrometer-statsd mongo-gorm mongo-reactive neo4j-bolt neo4j-gorm netflix-archius netflix-hystrix netflix-ribbon picocli postgres-reactive rabbitmq redis-lettuce security-jwt security-session spek spock springloaded tracing-jaeger tracing-zipkin" # --features values

  case ${CURR_WORD} in
    -l|--lang)
      COMPREPLY=( $( compgen -W "${LANG_OPTION_ARGS}" -- "" ) )
      return $?
      ;;
    -b|--build)
      COMPREPLY=( $( compgen -W "${BUILDTOOL_OPTION_ARGS}" -- "" ) )
      return $?
      ;;
    -p|--profile)
      COMPREPLY=( $( compgen -W "${PROFILE_OPTION_ARGS}" -- "" ) )
      return $?
      ;;
    -f|--features)
      COMPREPLY=( $( compgen -W "${FEATURE_OPTION_ARGS}" -- "" ) )
      return $?
      ;;
    *)
      case ${PREV_WORD} in
        -l|--lang)
          COMPREPLY=( $( compgen -W "${LANG_OPTION_ARGS}" -- $CURR_WORD ) )
          return $?
          ;;
        -b|--build)
          COMPREPLY=( $( compgen -W "${BUILDTOOL_OPTION_ARGS}" -- $CURR_WORD ) )
          return $?
          ;;
        -p|--profile)
          COMPREPLY=( $( compgen -W "${PROFILE_OPTION_ARGS}" -- $CURR_WORD ) )
          return $?
          ;;
        -f|--features)
          COMPREPLY=( $( compgen -W "${FEATURE_OPTION_ARGS}" -- $CURR_WORD ) )
          return $?
          ;;
      esac
  esac

  COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS} ${COMMANDS}" -- ${CURR_WORD}) )
}

# Generates completions for the options and subcommands of the `create-cli-app` subcommand.
function _picocli_mn_createcliapp() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-i --inplace -n --plain-output -x --stacktrace -v --verbose -h --help -V --version"
  ARG_OPTS="-l --lang -t --test -b --build -p --profile -f --features"
  LANG_OPTION_ARGS="java groovy kotlin" # SupportedLanguage values
  TEST_OPTION_ARGS="junit spock spek kotlintest" # SupportedTestFramework values
  BUILDTOOL_OPTION_ARGS="gradle maven" # SupportedBuildTool values
  PROFILE_OPTION_ARGS="base cli federation function function-aws kafka profile service base cli federation function function-aws kafka profile service" # --profile values
  FEATURE_OPTION_ARGS="annotation-api cassandra config-consul discovery-consul discovery-eureka groovy hibernate-gorm hibernate-jpa http-client http-server java jdbc-dbcp jdbc-hikari jdbc-tomcat jrebel junit kafka kafka-streams kotlin kotlintest management micrometer micrometer-atlas micrometer-graphite micrometer-prometheus micrometer-statsd mongo-gorm mongo-reactive neo4j-bolt neo4j-gorm netflix-archius netflix-hystrix netflix-ribbon picocli postgres-reactive rabbitmq redis-lettuce security-jwt security-session spek spock springloaded tracing-jaeger tracing-zipkin" # --features values

  case ${CURR_WORD} in
    -l|--lang)
      COMPREPLY=( $( compgen -W "${LANG_OPTION_ARGS}" -- "" ) )
      return $?
      ;;
    -t|--test)
      COMPREPLY=( $( compgen -W "${TEST_OPTION_ARGS}" -- "" ) )
      return $?
      ;;
    -b|--build)
      COMPREPLY=( $( compgen -W "${BUILDTOOL_OPTION_ARGS}" -- "" ) )
      return $?
      ;;
    -p|--profile)
      COMPREPLY=( $( compgen -W "${PROFILE_OPTION_ARGS}" -- "" ) )
      return $?
      ;;
    -f|--features)
      COMPREPLY=( $( compgen -W "${FEATURE_OPTION_ARGS}" -- "" ) )
      return $?
      ;;
    *)
      case ${PREV_WORD} in
        -l|--lang)
          COMPREPLY=( $( compgen -W "${LANG_OPTION_ARGS}" -- $CURR_WORD ) )
          return $?
          ;;
        -t|--test)
          COMPREPLY=( $( compgen -W "${TEST_OPTION_ARGS}" -- $CURR_WORD ) )
          return $?
          ;;
        -b|--build)
          COMPREPLY=( $( compgen -W "${BUILDTOOL_OPTION_ARGS}" -- $CURR_WORD ) )
          return $?
          ;;
        -p|--profile)
          COMPREPLY=( $( compgen -W "${PROFILE_OPTION_ARGS}" -- $CURR_WORD ) )
          return $?
          ;;
        -f|--features)
          COMPREPLY=( $( compgen -W "${FEATURE_OPTION_ARGS}" -- $CURR_WORD ) )
          return $?
          ;;
      esac
  esac

  COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS} ${COMMANDS}" -- ${CURR_WORD}) )
}

# Generates completions for the options and subcommands of the `create-federation` subcommand.
function _picocli_mn_createfederation() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-i --inplace -n --plain-output -x --stacktrace -v --verbose -h --help -V --version"
  ARG_OPTS="-s --services -b --build -p --profile -f --features"
  BUILDTOOL_OPTION_ARGS="gradle maven" # SupportedBuildTool values
  PROFILE_OPTION_ARGS="base cli federation function function-aws kafka profile service base cli federation function function-aws kafka profile service" # --profile values
  FEATURE_OPTION_ARGS="annotation-api cassandra config-consul discovery-consul discovery-eureka groovy hibernate-gorm hibernate-jpa http-client http-server java jdbc-dbcp jdbc-hikari jdbc-tomcat jrebel junit kafka kafka-streams kotlin kotlintest management micrometer micrometer-atlas micrometer-graphite micrometer-prometheus micrometer-statsd mongo-gorm mongo-reactive neo4j-bolt neo4j-gorm netflix-archius netflix-hystrix netflix-ribbon picocli postgres-reactive rabbitmq redis-lettuce security-jwt security-session spek spock springloaded tracing-jaeger tracing-zipkin" # --features values

  case ${CURR_WORD} in
    -b|--build)
      COMPREPLY=( $( compgen -W "${BUILDTOOL_OPTION_ARGS}" -- "" ) )
      return $?
      ;;
    -p|--profile)
      COMPREPLY=( $( compgen -W "${PROFILE_OPTION_ARGS}" -- "" ) )
      return $?
      ;;
    -f|--features)
      COMPREPLY=( $( compgen -W "${FEATURE_OPTION_ARGS}" -- "" ) )
      return $?
      ;;
    *)
      case ${PREV_WORD} in
        -b|--build)
          COMPREPLY=( $( compgen -W "${BUILDTOOL_OPTION_ARGS}" -- $CURR_WORD ) )
          return $?
          ;;
        -p|--profile)
          COMPREPLY=( $( compgen -W "${PROFILE_OPTION_ARGS}" -- $CURR_WORD ) )
          return $?
          ;;
        -f|--features)
          COMPREPLY=( $( compgen -W "${FEATURE_OPTION_ARGS}" -- $CURR_WORD ) )
          return $?
          ;;
      esac
  esac

  COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS} ${COMMANDS}" -- ${CURR_WORD}) )
}

# Generates completions for the options and subcommands of the `create-function` subcommand.
function _picocli_mn_createfunction() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-i --inplace -n --plain-output -x --stacktrace -v --verbose -h --help -V --version"
  ARG_OPTS="-r --provider -l --lang -t --test -b --build -p --profile -f --features"
  LANG_OPTION_ARGS="java groovy kotlin" # SupportedLanguage values
  TEST_OPTION_ARGS="junit spock spek kotlintest" # SupportedTestFramework values
  BUILDTOOL_OPTION_ARGS="gradle maven" # SupportedBuildTool values
  PROFILE_OPTION_ARGS="base cli federation function function-aws kafka profile service base cli federation function function-aws kafka profile service" # --profile values
  FEATURE_OPTION_ARGS="annotation-api cassandra config-consul discovery-consul discovery-eureka groovy hibernate-gorm hibernate-jpa http-client http-server java jdbc-dbcp jdbc-hikari jdbc-tomcat jrebel junit kafka kafka-streams kotlin kotlintest management micrometer micrometer-atlas micrometer-graphite micrometer-prometheus micrometer-statsd mongo-gorm mongo-reactive neo4j-bolt neo4j-gorm netflix-archius netflix-hystrix netflix-ribbon picocli postgres-reactive rabbitmq redis-lettuce security-jwt security-session spek spock springloaded tracing-jaeger tracing-zipkin" # --features values

  case ${CURR_WORD} in
    -l|--lang)
      COMPREPLY=( $( compgen -W "${LANG_OPTION_ARGS}" -- "" ) )
      return $?
      ;;
    -t|--test)
      COMPREPLY=( $( compgen -W "${TEST_OPTION_ARGS}" -- "" ) )
      return $?
      ;;
    -b|--build)
      COMPREPLY=( $( compgen -W "${BUILDTOOL_OPTION_ARGS}" -- "" ) )
      return $?
      ;;
    -p|--profile)
      COMPREPLY=( $( compgen -W "${PROFILE_OPTION_ARGS}" -- "" ) )
      return $?
      ;;
    -f|--features)
      COMPREPLY=( $( compgen -W "${FEATURE_OPTION_ARGS}" -- "" ) )
      return $?
      ;;
    *)
      case ${PREV_WORD} in
        -l|--lang)
          COMPREPLY=( $( compgen -W "${LANG_OPTION_ARGS}" -- $CURR_WORD ) )
          return $?
          ;;
        -t|--test)
          COMPREPLY=( $( compgen -W "${TEST_OPTION_ARGS}" -- $CURR_WORD ) )
          return $?
          ;;
        -b|--build)
          COMPREPLY=( $( compgen -W "${BUILDTOOL_OPTION_ARGS}" -- $CURR_WORD ) )
          return $?
          ;;
        -p|--profile)
          COMPREPLY=( $( compgen -W "${PROFILE_OPTION_ARGS}" -- $CURR_WORD ) )
          return $?
          ;;
        -f|--features)
          COMPREPLY=( $( compgen -W "${FEATURE_OPTION_ARGS}" -- $CURR_WORD ) )
          return $?
          ;;
      esac
  esac

  COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS} ${COMMANDS}" -- ${CURR_WORD}) )
}

# Generates completions for the options and subcommands of the `create-profile` subcommand.
function _picocli_mn_createprofile() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-i --inplace -n --plain-output -x --stacktrace -v --verbose -h --help -V --version"
  ARG_OPTS="-l --lang -b --build -p --profile -f --features"
  LANG_OPTION_ARGS="java groovy kotlin" # SupportedLanguage values
  BUILDTOOL_OPTION_ARGS="gradle maven" # SupportedBuildTool values
  PROFILE_OPTION_ARGS="base cli federation function function-aws kafka profile service base cli federation function function-aws kafka profile service" # --profile values
  FEATURE_OPTION_ARGS="" # --features values

  case ${CURR_WORD} in
    -l|--lang)
      COMPREPLY=( $( compgen -W "${LANG_OPTION_ARGS}" -- "" ) )
      return $?
      ;;
    -b|--build)
      COMPREPLY=( $( compgen -W "${BUILDTOOL_OPTION_ARGS}" -- "" ) )
      return $?
      ;;
    -p|--profile)
      COMPREPLY=( $( compgen -W "${PROFILE_OPTION_ARGS}" -- "" ) )
      return $?
      ;;
    -f|--features)
      COMPREPLY=( $( compgen -W "${FEATURE_OPTION_ARGS}" -- "" ) )
      return $?
      ;;
    *)
      case ${PREV_WORD} in
        -l|--lang)
          COMPREPLY=( $( compgen -W "${LANG_OPTION_ARGS}" -- $CURR_WORD ) )
          return $?
          ;;
        -b|--build)
          COMPREPLY=( $( compgen -W "${BUILDTOOL_OPTION_ARGS}" -- $CURR_WORD ) )
          return $?
          ;;
        -p|--profile)
          COMPREPLY=( $( compgen -W "${PROFILE_OPTION_ARGS}" -- $CURR_WORD ) )
          return $?
          ;;
        -f|--features)
          COMPREPLY=( $( compgen -W "${FEATURE_OPTION_ARGS}" -- $CURR_WORD ) )
          return $?
          ;;
      esac
  esac

  COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS} ${COMMANDS}" -- ${CURR_WORD}) )
}

# Generates completions for the options and subcommands of the `help` subcommand.
function _picocli_mn_help() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-h --help"
  ARG_OPTS=""

  COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS} ${COMMANDS}" -- ${CURR_WORD}) )
}

# Generates completions for the options and subcommands of the `list-profiles` subcommand.
function _picocli_mn_listprofiles() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-n --plain-output -x --stacktrace -v --verbose -h --help -V --version"
  ARG_OPTS=""

  COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS} ${COMMANDS}" -- ${CURR_WORD}) )
}

# Generates completions for the options and subcommands of the `profile-info` subcommand.
function _picocli_mn_profileinfo() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS="-n --plain-output -x --stacktrace -v --verbose -h --help -V --version"
  ARG_OPTS=""

  COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS} ${COMMANDS}" -- ${CURR_WORD}) )
}

# Generates completions for the options and subcommands of the `!` subcommand.
function _picocli_mn_() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS=""
  ARG_OPTS=""

  COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS} ${COMMANDS}" -- ${CURR_WORD}) )
}

# Generates completions for the options and subcommands of the `exit` subcommand.
function _picocli_mn_exit() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS=""
  ARG_OPTS=""

  COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS} ${COMMANDS}" -- ${CURR_WORD}) )
}

# Generates completions for the options and subcommands of the `quit` subcommand.
function _picocli_mn_quit() {
  # Get completion data
  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}

  COMMANDS=""
  FLAG_OPTS=""
  ARG_OPTS=""

  COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS} ${COMMANDS}" -- ${CURR_WORD}) )
}

# Define a completion specification (a compspec) for the
# `mn`, `mn.sh`, and `mn.bash` commands.
# Uses the bash `complete` builtin (see [6]) to specify that shell function
# `_complete_mn` is responsible for generating possible completions for the
# current word on the command line.
# The `-o default` option means that if the function generated no matches, the
# default Bash completions and the Readline default filename completions are performed.
complete -F _complete_mn -o default mn mn.sh mn.bash




© 2015 - 2025 Weber Informatics LLC | Privacy Policy