github.com/defang-io/defang/src@v0.0.0-20240505002154-bdf411911834/bin/completions.sh (about)

     1  #!/bin/sh
     2  # Generate all shell completions for defang
     3  # Usage: ./completions.sh [path/to/defang]
     4  
     5  set -e # Exit on error
     6  
     7  OUTPUT_DIR=$PWD
     8  SCRIPT_DIR=`dirname "$0"`
     9  DEFANG=$1
    10  
    11  # If no path to the defang CLI is provided, use Go to build and run it
    12  if [ -z "$DEFANG" ]; then
    13    DEFANG="go run ./cmd/cli/main.go"
    14    cd "$SCRIPT_DIR/.."
    15  fi
    16  
    17  for sh in bash zsh fish powershell; do
    18    $DEFANG completion "$sh" >"$OUTPUT_DIR/defang.$sh"
    19  done