Skip to content

Commit

Permalink
stubbing out commands. finishing test infrastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
progrium committed Nov 23, 2014
1 parent 9ce3de1 commit 0301171
Show file tree
Hide file tree
Showing 20 changed files with 1,622 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
herokuish
release
build
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright (C) 2014 Jeff Lindsay

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 changes: 26 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
NAME=herokuish
HARDWARE=$(shell uname -m)
VERSION=0.1.0

build:
go-bindata bash
rm -rf build
mkdir -p build/linux && GOOS=linux go build -o build/linux/$(NAME)
mkdir -p build/darwin && GOOS=darwin go build -o build/darwin/$(NAME)

test: build
tests/shunit2 tests/**/tests.sh

release: test
rm -rf release
mkdir release
cp build/linux/$(NAME) release/$(NAME)
cd release && tar -zcf $(NAME)_$(VERSION)_linux_$(HARDWARE).tgz $(NAME)
cp build/darwin/$(NAME) release/$(NAME)
cd release && tar -zcf $(NAME)_$(VERSION)_darwin_$(HARDWARE).tgz $(NAME)
rm release/$(NAME)
echo "$(VERSION)" > release/version
echo "gliderlabs/$(NAME)" > release/repo
gh-release # https://github.com/progrium/gh-release

.PHONY: build test release
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# herokuish

[![Circle CI](https://circleci.com/gh/gliderlabs/herokuish.png?style=shield)](https://circleci.com/gh/gliderlabs/herokuish)
1 change: 1 addition & 0 deletions SPONSORS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Deis Project http://deis.io
10 changes: 10 additions & 0 deletions bash/buildpack.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

buildpack-build() {
declare desc="Build an application using installed buildpacks"
echo "ok done"
}

buildpack-install() {
declare desc="Install buildpack from Git URL and optional committish"
echo "installing"
}
78 changes: 78 additions & 0 deletions bash/cmd.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@

declare -A CMDS

cmd-list() {
declare desc="Lists available commands"
declare ns="$1"
cmd-list-keys "$ns" | sed "s/$ns://"
}

cmd-list-keys() {
declare ns="$1"
for k in "${!CMDS[@]}"; do
echo "$k"
done | grep "^$ns:" | sort
}

cmd-list-ns() {
for k in "${!CMDS[@]}"; do
echo "$k"
done | grep -v : | sort
}

cmd-export() {
declare desc="Exports a function as a command"
declare fn="$1" as="${2:-$1}"
local ns=""
for n in $(cmd-list-ns); do
echo "$fn" | grep "^$n-" &> /dev/null && ns="$n"
done
CMDS["$ns:${as/#$ns-/}"]="$fn"
}

cmd-export-ns() {
declare ns="$1" desc="$2"
eval "$1() {
declare desc=\"$desc\"
cmd-ns $1 \"\$@\";
}"
cmd-export "$1"
CMDS["$1"]="$1"
}

cmd-ns() {
local ns="$1"; shift
local cmd="$1"; shift || true
local status=0
if cmd-list "$ns" | grep ^$cmd\$ &> /dev/null; then
${CMDS["$ns:$cmd"]} "$@"
else
if [[ "$cmd" ]]; then
echo "No such command: $cmd"
status=2
elif [[ "$ns" ]]; then
echo "$(fn-desc "$ns")"
fi
echo
echo "Available commands:"
for cmd in $(cmd-list "$ns"); do
printf " %-28s %s\n" "$cmd" "$(fn-desc "${CMDS["$ns:$cmd"]}")"
done
echo
exit $status
fi
}

cmd-help() {
declare desc="Shows help information for a command"
declare args="$@"
if [[ "$args" ]]; then
for cmd; do true; done # last arg
local ns="${args/%$cmd/}"; ns="${ns/% /}"; ns="${ns/ /-}"
local fn="${CMDS["$ns:$cmd"]}"
fn-info "$fn" 1
else
cmd-ns ""
fi
}
cmd-export cmd-help help
24 changes: 24 additions & 0 deletions bash/fn.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

fn-args() {
declare desc="Inspect a function's arguments"
local argline=$(type $1 | grep declare | grep -v "declare desc" | head -1)
echo -e "${argline// /"\n"}" | awk -F= '/=/{print "<"$1">"}' | tr "\n" " "
}

fn-desc() {
declare desc="Inspect a function's description"
desc=""
eval "$(type $1 | grep desc | head -1)"; echo $desc
}

fn-info() {
declare desc="Inspects a function"
declare fn="$1" showsource="$2"
echo "$fn $(fn-args $fn)"
echo " $(fn-desc $fn)"
echo
if [[ "$showsource" ]]; then
type $fn | tail -n +2
echo
fi
}
27 changes: 27 additions & 0 deletions bash/herokuish.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

if [[ "$BASH_VERSINFO" -lt "4" ]]; then
echo "!! Your system Bash is out of date: $BASH_VERSION"
echo "!! Please upgrade to Bash 4 or greater."
exit 2
fi

main() {
set -eo pipefail; [[ "$TRACE" ]] && set -x
export BASH_ENV=

cmd-export-ns buildpack "Use and install buildpacks"
cmd-export buildpack-build
cmd-export buildpack-install

cmd-export-ns slug "Manage application slugs"
cmd-export slug-import
cmd-export slug-generate
cmd-export slug-export

cmd-export-ns procfile "Parse and execute Procfiles"
cmd-export procfile-start
cmd-export procfile-exec
cmd-export procfile-parse

cmd-ns "" "$@"
}
12 changes: 12 additions & 0 deletions bash/procfile.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

procfile-start() {
true
}

procfile-exec() {
true
}

procfile-parse() {
true
}
12 changes: 12 additions & 0 deletions bash/slug.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

slug-import() {
true
}

slug-generate() {
true
}

slug-export() {
true
}
Loading

0 comments on commit 0301171

Please sign in to comment.