Skip to content

Create downloadable top-level ./go script boilerplate #144

@mbland

Description

@mbland

And here's the implementation:

#! /usr/bin/env bash

readonly SCRIPTS_DIR="${0%/*}/bin"
readonly GO_SCRIPT_CORE="$SCRIPTS_DIR/go-script-bash/go-core.bash"
readonly GO_SCRIPT_CORE_URL='https://github.com/mbland/go-script-bash.git'
readonly GO_SCRIPT_CORE_VERSION='master'

if [[ ! -e "$GO_SCRIPT_CORE" ]]; then
  if ! git clone --depth 1 -c advice.detachedHead=false \
      -b "$GO_SCRIPT_CORE_VERSION" "$GO_SCRIPT_CORE_URL" \
      "${GO_SCRIPT_CORE%/*}" &>/dev/null; then
    printf 'Failed to clone %s; aborting.\n' "$GO_SCRIPT_CORE_URL" >&2
    exit 1
  fi
fi

. "$GO_SCRIPT_CORE" 'bin'
@go "$@"

This presumes the _GO_SCRIPTS_DIR will be bin, and there may need to be documentation around how to have one script for the main application/plugin and a separate ./go script for development.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions