#!/usr/bin/env bash
#
# Copyright 2016 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Set PROGram name
PROG=${0##*/}
########################################################################
#+ NAME
#+     $PROG - Create a kubernetes release script template
#+
#+ SYNOPSIS
#+     $PROG
#+     $PROG [--help | -man]
#+     $PROG [--usage | -?]
#+
#+ DESCRIPTION
#+     $PROG produces a general template for use within the kubernetes/release
#+     script/tool ecosystem with a *nix-style header and some useful comments
#+     to get you started.
#+
#+ OPTIONS
#+     [--help | -man] - display man page for this script
#+     [--usage | -?]  - display usage information
#+
#+ EXAMPLES
#+
#+ FILES
#+
#+ SEE ALSO
#+
#+ BUGS
#+
#-
########################################################################
source $(dirname $(readlink -ne $0))/lib/common.sh

cat <<EOF_CAT
#!/usr/bin/env bash
#
# Copyright 2016 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Set PROGram name
PROG=\${0##*/}
########################################################################
#+
#+ NAME
#+     \$PROG - Short description
#+
#+ SYNOPSIS
#+     \$PROG  --requiredarg=<value1|value2> [--optionalarg=[value1|value2]]
#+     \$PROG  [--helpshort|--usage|-?]
#+     \$PROG  [--help|-man]
#+
#+ DESCRIPTION
#+     Detailed description of script and options
#+
#+ OPTIONS
#+     --requiredarg=            - Detail of --requiredarg
#+     [--optionalarg=]          - Detail of option2 and arguments
#+     [--help | -man]           - display man page for this script
#+     [--usage | -?]            - display in-line usage
#+
#+ EXAMPLES
#+     \$PROG --requiredarg=value - How script works with --requiredarg=value
#+     \$PROG --optionalarg=value - How script works with --optionalarg=value
#+
#+ FILES
#+     Applicable files
#+     Related files
#+
#+ SEE ALSO
#+     common.sh                 - base function definitions
#+     Other related scripts
#+
#+ BUGS/TODO
#+     Known problems with script
#+
########################################################################
# If NO ARGUMENTS should return *usage*, uncomment the following line:
#usage=\${1:-yes}

source \$(dirname \$(readlink -ne \$BASH_SOURCE))/lib/common.sh

# Process Command-line arguments
# POSITIONAL_ARGV is provided by common::namevalue after arg preprocessing
# * --name=value becomes FLAGS_name=value
# * --name becomes FLAGS_name=1 (boolean)

# Optionally validate number of POSITIONAL_ARGV
#common::argc_validate 2

###############################################################################
# FUNCTIONS
###############################################################################
# OPTIONAL: Overwrite common.sh's common::cleanexit
#common::cleanexit () {
#rm -rf \$TMPDIR \$TMPFILE
#tput cnorm
#
## Do stuff here to clean up after this specific script
#
#common::timestamp end
#exit \${1:-0}
#}


###############################################################################
# MAIN
###############################################################################

##############################################################################
# Initialize logs
##############################################################################
# Initialize and save up to 10 (rotated logs)
#MYLOG=\$TMPDIR/\$PROG.log
#common::logfileinit \$MYLOG 10
# BEGIN script
common::timestamp begin

##############################################################################
# OTHER HELPFUL FUNCTIONS (More in common.sh)
##############################################################################
# logecho - echo to stdout and MYLOG if set
# logrun - run a cmd to stdout and MYLOG if set
# common::askyorn - Ask a simple yes or no question (see common.sh for details)
# common::stepheader - Bolded, logged bullet points for your output
# common::exit - Exit cleanly
# common::check_packages - Check for package prereqs
# common::disk_space_check - Check disk space


##############################################################################
common::stepheader MAJOR STEP 1
##############################################################################


##############################################################################
common::stepheader MAJOR STEP 2
##############################################################################


# END script
common::timestamp end
EOF_CAT
