From 993584f0f06da314f2991104e72e80358ac1ad73 Mon Sep 17 00:00:00 2001 From: Markos Rendell Date: Thu, 18 Aug 2016 17:04:25 +0100 Subject: [PATCH 1/2] Adding cartridge subcommand to CLI and bat tests --- cmd/cartridge | 201 ++++++++++++++++++++++++++++++++++++++++++++ test/cartridge.bats | 74 ++++++++++++++++ 2 files changed, 275 insertions(+) create mode 100644 cmd/cartridge create mode 100644 test/cartridge.bats diff --git a/cmd/cartridge b/cmd/cartridge new file mode 100644 index 000000000..b321da9e1 --- /dev/null +++ b/cmd/cartridge @@ -0,0 +1,201 @@ +#!/bin/bash -e + +SUB_CMD_NAME="cartridge" +source ${CLI_DIR}/lib/adop_lib.sh + +# Templates to build the cartridge from\ +declare -A templates +templates['example']=https://github.com/Accenture/adop-cartridge-skeleton.git +# TODO actually need a node template! +templates['node']=https://github.com/Accenture/adop-cartridge-skeleton.git +templates['java']=https://github.com/Accenture/adop-cartridge-java.git +templates['docker']=https://github.com/Accenture/adop-cartridge-docker.git +templates['chef']=https://github.com/Accenture/adop-cartridge-chef.git + + +list_init_templates() { + printf "\nThe following templates can be used to build your inital cartridge. (The default is example.)\n\n" + for name in ${!templates[@]}; do + printf "${name}:\t${templates[$name]}\n" + done +} + +list_template_names() { + for name in ${!templates[@]}; do + printf "${name} " + done +} + +list_template_urls() { + for name in ${templates[@]}; do + echo $name + done +} + +cmd_desc() { + echo "For creating cartridges." +} + +cmd_usage() { + echo "usage: ${CMD_NAME} ${SUB_CMD_NAME} " +} + +help() { + cmd_usage + echo + echo "Available subcommands are:" + printf " %-30s %s\n" "init []" "Create a cartridge skeleton in the current directory." + printf " %-30s %s\n" "list_init_templates []" "List the templates that can be used to initialise a new cartridge in your currently working directory." + echo + echo "Try '${CMD_NAME} ${SUB_CMD_NAME} -h' for details." + echo "HINT: Run '${CMD_NAME} ${SUB_CMD_NAME} init' to create a cartridge in the current directory" + echo +} + +init_help() { + echo + echo "usage: ${CMD_NAME} ${SUB_CMD_NAME} init []" + printf " %-2s %s\n" "" "Options:" + printf " %-3s %s\n" "" "-s : Name of subfolder create the cartridge in (Optional) (Default : adop)" + printf " %-3s %s\n" "" "-t