Skip to content

Commit

Permalink
Merge pull request #15 from gliderlabs/master
Browse files Browse the repository at this point in the history
v0.0.7
  • Loading branch information
andyshinn committed Feb 21, 2015
2 parents daec54f + ad356e2 commit 4e19043
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
build
release
bindata.go
bindata.go
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@ All notable changes to this project will be documented in this file.

### Changed

## [0.0.7] - 2015-02-20
### Added
- Support for `Gunfile` as global module / profile
- Support for projects without profiles, just `Gunfile`
- Support for `init()` in profiles and `Gunfile`
- Support for `-h` and `--help` as last argument
- `.gun` and `Gunfile.*` added to `.gitignore` on `gun init`

### Removed
- Stopped listing second level commands

### Changed
- Using `Gunfile` to detect glidergun project instead of `.gun`
- Profiles now use `Gunfile.<name>` instead of `.gun_<name>`

## [0.0.6] - 2015-02-16
### Fixed
- Resolved issue where `deps-require` downloads wrong binary
Expand Down Expand Up @@ -55,7 +70,8 @@ All notable changes to this project will be documented in this file.
### Fixed
- Fixed profiles not loading

[unreleased]: https://github.com/gliderlabs/glidergun/compare/v0.0.6...HEAD
[unreleased]: https://github.com/gliderlabs/glidergun/compare/v0.0.7...HEAD
[0.0.7]: https://github.com/gliderlabs/glidergun/compare/v0.0.6...v0.0.7
[0.0.6]: https://github.com/gliderlabs/glidergun/compare/v0.0.5...v0.0.6
[0.0.5]: https://github.com/gliderlabs/glidergun/compare/v0.0.4...v0.0.5
[0.0.4]: https://github.com/gliderlabs/glidergun/compare/v0.0.3...v0.0.4
Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
NAME=glidergun
BINARYNAME=gun
ARCH=$(shell uname -m)
VERSION=0.0.6
VERSION=0.0.7

build:
go-bindata include
Expand All @@ -16,11 +16,14 @@ deps:
go get -u github.com/progrium/gh-release/...
go get || true

release: build
release:
rm -rf release && mkdir release
tar -zcf release/$(NAME)_$(VERSION)_Linux_$(ARCH).tgz -C build/Linux $(BINARYNAME)
tar -zcf release/$(NAME)_$(VERSION)_Darwin_$(ARCH).tgz -C build/Darwin $(BINARYNAME)
gh-release checksums sha256
gh-release create gliderlabs/$(NAME) $(VERSION) $(shell git rev-parse --abbrev-ref HEAD) v$(VERSION)

clean:
rm -rf build release

.PHONY: build release
12 changes: 6 additions & 6 deletions include/cmd.bash
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ cmd-export() {

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

cmd-ns() {
local ns="$1"; shift
local ns="$1"; shift
local cmd="$1"; shift || true
local status=0
if cmd-list "$ns" | grep ^$cmd\$ &> /dev/null; then
Expand All @@ -58,9 +58,9 @@ cmd-ns() {
echo "Available commands:"
for cmd in $(cmd-list "$ns"); do
printf " %-24s %s\n" "$cmd" "$(fn-desc "${CMDS["$ns:$cmd"]}")"
for subcmd in $(cmd-list "$cmd"); do
printf " %-24s %s\n" "$subcmd" "$(fn-desc "${CMDS["$cmd:$subcmd"]}")"
done
#for subcmd in $(cmd-list "$cmd"); do
# printf " %-24s %s\n" "$subcmd" "$(fn-desc "${CMDS["$cmd:$subcmd"]}")"
#done
done
echo
exit $status
Expand Down
3 changes: 2 additions & 1 deletion include/env.bash
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ env-import() {
}

env-show() {
declare desc="Shows relevant environment variables"
local longest=0
for var in "${_env[@]}"; do
if [[ "${#var}" -gt "$longest" ]]; then
Expand All @@ -24,4 +25,4 @@ env-show() {
for var in "${_env[@]}"; do
printf "%-${longest}s = %s\n" "$var" "${!var}"
done
}
}
6 changes: 3 additions & 3 deletions include/fn.bash
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ fn-info() {
echo " $(fn-desc $fn)"
echo
if [[ "$showsource" ]]; then
type $fn
declare -f "$fn" | tail -n +1
echo
fi
}

fn-source() {
declare desc="Shows function source"
declare fn="$1"
declare -f $fn | tail -n +2
declare -f "$fn" | tail -n +2
}

fn-call() {
declare desc="Run arbitrary function"
declare fn="$1"; shift
$fn "$@"
"$fn" "$@"
}
53 changes: 28 additions & 25 deletions include/gun.bash
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ declare GUN_MODULE_DIR="${GUN_MODULE_DIR:-cmds}"

gun-init() {
declare desc="Initialize a glidergun project directory"
mkdir .gun
echo "*" > .gun/.gitignore
echo "!.gitignore" >> .gun/.gitignore
touch Gunfile
mkdir -p .gun
if [[ -f .gitignore ]]; then
printf "\n.gun\nGunfile.*\n" >> .gitignore
fi
}

gun-version() {
Expand Down Expand Up @@ -37,10 +39,10 @@ gun-update() {

gun-find-root() {
local path="$PWD"
while [[ "$path" != "" && ! -d "$path/.gun" ]]; do
while [[ "$path" != "" && ! -f "$path/Gunfile" ]]; do
path="${path%/*}"
done
if [[ -d "$path/.gun" ]]; then
if [[ -f "$path/Gunfile" ]]; then
GUN_ROOT="$path"
cd "$GUN_ROOT"
fi
Expand All @@ -50,36 +52,37 @@ main() {
set -eo pipefail; [[ "$TRACE" ]] && set -x
color-init
gun-find-root

if [[ "$GUN_ROOT" ]]; then
deps-init
if [[ -f ".gun_$1" ]]; then
source ".gun_$1"
module-load "Gunfile"
if [[ -f "Gunfile.$1" ]]; then
module-load "Gunfile.$1"
GUN_PROFILE="$1"
shift
elif [[ "$GUN_DEFAULT_PROFILE" && -f ".gun_$GUN_DEFAULT_PROFILE" ]]; then
source ".gun_$GUN_DEFAULT_PROFILE"
elif [[ "$GUN_DEFAULT_PROFILE" && -f "Gunfile.$GUN_DEFAULT_PROFILE" ]]; then
module-load "Gunfile.$GUN_DEFAULT_PROFILE"
echo "* Using default profile $GUN_DEFAULT_PROFILE" | yellow
GUN_PROFILE="$GUN_DEFAULT_PROFILE"
fi
if [[ "$GUN_PROFILE" ]]; then
if [[ -d "$GUN_MODULE_DIR" ]]; then
module-load-dir "$GUN_MODULE_DIR"
fi
cmd-export env-show env
cmd-export fn-call fn
else
local builtins=(init version help selfupdate)
if ! [[ ${builtins[*]} =~ "$1" ]]; then
echo "* Unable to load profile $1" | yellow
fi
if [[ -d "$GUN_MODULE_DIR" ]]; then
module-load-dir "$GUN_MODULE_DIR"
fi
cmd-export env-show env
cmd-export fn-call fn
else
cmd-export gun-init init
fi

cmd-export gun-init init
cmd-export cmd-help help
cmd-export gun-version version
cmd-export gun-update update

cmd-ns "" "$@"
}

if [[ "${!#}" == "-h" || "${!#}" == "--help" ]]; then
local args=("$@")
unset args[${#args[@]}-1]
cmd-ns "" help "${args[@]}"
else
cmd-ns "" "$@"
fi
}
9 changes: 9 additions & 0 deletions tests/project/Gunfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

init() {
cmd-export hello
}

hello() {
declare desc="Says hello"
echo "Hello!"
}
File renamed without changes.
File renamed without changes.
5 changes: 2 additions & 3 deletions tests/project/cmds/bar.bash
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@


init() {
cmd-export-ns bar
cmd-export-ns bar "Bar namespace"
cmd-export bar-hello
deps-require jq 1.4
}

bar-hello() {
echo "Hello from bar"
}
}
4 changes: 2 additions & 2 deletions tests/project/cmds/foo.bash
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@


init() {
cmd-export-ns foo
cmd-export-ns foo "Foo namespace"
cmd-export foo-hello
}

foo-hello() {
echo "Hello from foo"
}
}

0 comments on commit 4e19043

Please sign in to comment.