You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by ge...@apache.org on 2018/03/23 13:50:48 UTC

[21/25] brooklyn-client git commit: Add vendor file and remove glide from build/readme

http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/799e9ccb/cli/vendor/github.com/NodePrime/jsonpath/misc.go
----------------------------------------------------------------------
diff --git a/cli/vendor/github.com/NodePrime/jsonpath/misc.go b/cli/vendor/github.com/NodePrime/jsonpath/misc.go
new file mode 100644
index 0000000..0e9ec2c
--- /dev/null
+++ b/cli/vendor/github.com/NodePrime/jsonpath/misc.go
@@ -0,0 +1,181 @@
+package jsonpath
+
+import (
+	"errors"
+	"fmt"
+)
+
+func takeExponent(l lexer) error {
+	r := l.peek()
+	if r != 'e' && r != 'E' {
+		return nil
+	}
+	l.take()
+	r = l.take()
+	switch r {
+	case '+', '-':
+		// Check digit immediately follows sign
+		if d := l.peek(); !(d >= '0' && d <= '9') {
+			return fmt.Errorf("Expected digit after numeric sign instead of %#U", d)
+		}
+		takeDigits(l)
+	case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
+		takeDigits(l)
+	default:
+		return fmt.Errorf("Expected digit after 'e' instead of %#U", r)
+	}
+	return nil
+}
+
+func takeJSONNumeric(l lexer) error {
+	cur := l.take()
+	switch cur {
+	case '-':
+		// Check digit immediately follows sign
+		if d := l.peek(); !(d >= '0' && d <= '9') {
+			return fmt.Errorf("Expected digit after dash instead of %#U", d)
+		}
+		takeDigits(l)
+	case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
+		takeDigits(l)
+	default:
+		return fmt.Errorf("Expected digit or dash instead of %#U", cur)
+	}
+
+	// fraction or exponent
+	cur = l.peek()
+	switch cur {
+	case '.':
+		l.take()
+		// Check digit immediately follows period
+		if d := l.peek(); !(d >= '0' && d <= '9') {
+			return fmt.Errorf("Expected digit after '.' instead of %#U", d)
+		}
+		takeDigits(l)
+		if err := takeExponent(l); err != nil {
+			return err
+		}
+	case 'e', 'E':
+		if err := takeExponent(l); err != nil {
+			return err
+		}
+	}
+
+	return nil
+}
+
+func takeDigits(l lexer) {
+	for {
+		d := l.peek()
+		if d >= '0' && d <= '9' {
+			l.take()
+		} else {
+			break
+		}
+	}
+}
+
+// Only used at the very beginning of parsing. After that, the emit() function
+// automatically skips whitespace.
+func ignoreSpaceRun(l lexer) {
+	for {
+		r := l.peek()
+		if r == ' ' || r == '\t' || r == '\r' || r == '\n' {
+			l.take()
+		} else {
+			break
+		}
+	}
+	l.ignore()
+}
+
+func takeExactSequence(l lexer, str []byte) bool {
+	for _, r := range str {
+		v := l.take()
+		if v != int(r) {
+			return false
+		}
+	}
+	return true
+}
+
+func readerToArray(tr tokenReader) []Item {
+	vals := make([]Item, 0)
+	for {
+		i, ok := tr.next()
+		if !ok {
+			break
+		}
+		v := *i
+		s := make([]byte, len(v.val))
+		copy(s, v.val)
+		v.val = s
+		vals = append(vals, v)
+	}
+	return vals
+}
+
+func findErrors(items []Item) (Item, bool) {
+	for _, i := range items {
+		if i.typ == lexError {
+			return i, true
+		}
+	}
+	return Item{}, false
+}
+
+func byteSlicesEqual(a, b []byte) bool {
+	if len(a) != len(b) {
+		return false
+	}
+
+	for i := range a {
+		if a[i] != b[i] {
+			return false
+		}
+	}
+
+	return true
+}
+
+func firstError(errors ...error) error {
+	for _, e := range errors {
+		if e != nil {
+			return e
+		}
+	}
+	return nil
+}
+
+func abs(x int) int {
+	switch {
+	case x < 0:
+		return -x
+	case x == 0:
+		return 0 // return correctly abs(-0)
+	}
+	return x
+}
+
+//TODO: Kill the need for this
+func getJsonTokenType(val []byte) (int, error) {
+	if len(val) == 0 {
+		return -1, errors.New("No Value")
+	}
+	switch val[0] {
+	case '{':
+		return jsonBraceLeft, nil
+	case '"':
+		return jsonString, nil
+	case '[':
+		return jsonBracketLeft, nil
+	case 'n':
+		return jsonNull, nil
+	case 't', 'b':
+		return jsonBool, nil
+	case '-', '+', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
+		return jsonNumber, nil
+	default:
+		return -1, errors.New("Unrecognized Json Value")
+	}
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/799e9ccb/cli/vendor/github.com/NodePrime/jsonpath/path.go
----------------------------------------------------------------------
diff --git a/cli/vendor/github.com/NodePrime/jsonpath/path.go b/cli/vendor/github.com/NodePrime/jsonpath/path.go
new file mode 100644
index 0000000..9d142b5
--- /dev/null
+++ b/cli/vendor/github.com/NodePrime/jsonpath/path.go
@@ -0,0 +1,208 @@
+package jsonpath
+
+import (
+	"errors"
+	"fmt"
+	"strconv"
+)
+
+const (
+	opTypeIndex = iota
+	opTypeIndexRange
+	opTypeIndexWild
+	opTypeName
+	opTypeNameList
+	opTypeNameWild
+)
+
+type Path struct {
+	stringValue     string
+	operators       []*operator
+	captureEndValue bool
+}
+
+type operator struct {
+	typ         int
+	indexStart  int
+	indexEnd    int
+	hasIndexEnd bool
+	keyStrings  map[string]struct{}
+
+	whereClauseBytes []byte
+	dependentPaths   []*Path
+	whereClause      []Item
+}
+
+func genIndexKey(tr tokenReader) (*operator, error) {
+	k := &operator{}
+	var t *Item
+	var ok bool
+	if t, ok = tr.next(); !ok {
+		return nil, errors.New("Expected number, key, or *, but got none")
+	}
+
+	switch t.typ {
+	case pathWildcard:
+		k.typ = opTypeIndexWild
+		k.indexStart = 0
+		if t, ok = tr.next(); !ok {
+			return nil, errors.New("Expected ] after *, but got none")
+		}
+		if t.typ != pathBracketRight {
+			return nil, fmt.Errorf("Expected ] after * instead of %q", t.val)
+		}
+	case pathIndex:
+		v, err := strconv.Atoi(string(t.val))
+		if err != nil {
+			return nil, fmt.Errorf("Could not parse %q into int64", t.val)
+		}
+		k.indexStart = v
+		k.indexEnd = v
+		k.hasIndexEnd = true
+
+		if t, ok = tr.next(); !ok {
+			return nil, errors.New("Expected number or *, but got none")
+		}
+		switch t.typ {
+		case pathIndexRange:
+			if t, ok = tr.next(); !ok {
+				return nil, errors.New("Expected number or *, but got none")
+			}
+			switch t.typ {
+			case pathIndex:
+				v, err := strconv.Atoi(string(t.val))
+				if err != nil {
+					return nil, fmt.Errorf("Could not parse %q into int64", t.val)
+				}
+				k.indexEnd = v - 1
+				k.hasIndexEnd = true
+
+				if t, ok = tr.next(); !ok || t.typ != pathBracketRight {
+					return nil, errors.New("Expected ], but got none")
+				}
+			case pathBracketRight:
+				k.hasIndexEnd = false
+			default:
+				return nil, fmt.Errorf("Unexpected value within brackets after index: %q", t.val)
+			}
+
+			k.typ = opTypeIndexRange
+		case pathBracketRight:
+			k.typ = opTypeIndex
+		default:
+			return nil, fmt.Errorf("Unexpected value within brackets after index: %q", t.val)
+		}
+	case pathKey:
+		k.keyStrings = map[string]struct{}{string(t.val[1 : len(t.val)-1]): struct{}{}}
+		k.typ = opTypeName
+
+		if t, ok = tr.next(); !ok || t.typ != pathBracketRight {
+			return nil, errors.New("Expected ], but got none")
+		}
+	default:
+		return nil, fmt.Errorf("Unexpected value within brackets: %q", t.val)
+	}
+
+	return k, nil
+}
+
+func parsePath(pathString string) (*Path, error) {
+	lexer := NewSliceLexer([]byte(pathString), PATH)
+	p, err := tokensToOperators(lexer)
+	if err != nil {
+		return nil, err
+	}
+
+	p.stringValue = pathString
+
+	//Generate dependent paths
+	for _, op := range p.operators {
+		if len(op.whereClauseBytes) > 0 {
+			var err error
+			trimmed := op.whereClauseBytes[1 : len(op.whereClauseBytes)-1]
+			whereLexer := NewSliceLexer(trimmed, EXPRESSION)
+			items := readerToArray(whereLexer)
+			if errItem, found := findErrors(items); found {
+				return nil, errors.New(string(errItem.val))
+			}
+
+			// transform expression into postfix form
+			op.whereClause, err = infixToPostFix(items[:len(items)-1]) // trim EOF
+			if err != nil {
+				return nil, err
+			}
+			op.dependentPaths = make([]*Path, 0)
+			// parse all paths in expression
+			for _, item := range op.whereClause {
+				if item.typ == exprPath {
+					p, err := parsePath(string(item.val))
+					if err != nil {
+						return nil, err
+					}
+					op.dependentPaths = append(op.dependentPaths, p)
+				}
+			}
+		}
+	}
+	return p, nil
+}
+
+func tokensToOperators(tr tokenReader) (*Path, error) {
+	q := &Path{
+		stringValue:     "",
+		captureEndValue: false,
+		operators:       make([]*operator, 0),
+	}
+	for {
+		p, ok := tr.next()
+		if !ok {
+			break
+		}
+		switch p.typ {
+		case pathRoot:
+			if len(q.operators) != 0 {
+				return nil, errors.New("Unexpected root node after start")
+			}
+			continue
+		case pathCurrent:
+			if len(q.operators) != 0 {
+				return nil, errors.New("Unexpected current node after start")
+			}
+			continue
+		case pathPeriod:
+			continue
+		case pathBracketLeft:
+			k, err := genIndexKey(tr)
+			if err != nil {
+				return nil, err
+			}
+			q.operators = append(q.operators, k)
+		case pathKey:
+			keyName := p.val
+			if len(p.val) == 0 {
+				return nil, fmt.Errorf("Key length is zero at %d", p.pos)
+			}
+			if p.val[0] == '"' && p.val[len(p.val)-1] == '"' {
+				keyName = p.val[1 : len(p.val)-1]
+			}
+			q.operators = append(q.operators, &operator{typ: opTypeName, keyStrings: map[string]struct{}{string(keyName): struct{}{}}})
+		case pathWildcard:
+			q.operators = append(q.operators, &operator{typ: opTypeNameWild})
+		case pathValue:
+			q.captureEndValue = true
+		case pathWhere:
+		case pathExpression:
+			if len(q.operators) == 0 {
+				return nil, errors.New("Cannot add where clause on last key")
+			}
+			last := q.operators[len(q.operators)-1]
+			if last.whereClauseBytes != nil {
+				return nil, errors.New("Expression on last key already set")
+			}
+			last.whereClauseBytes = p.val
+		case pathError:
+			return q, errors.New(string(p.val))
+		}
+	}
+	return q, nil
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/799e9ccb/cli/vendor/github.com/NodePrime/jsonpath/path_states.go
----------------------------------------------------------------------
diff --git a/cli/vendor/github.com/NodePrime/jsonpath/path_states.go b/cli/vendor/github.com/NodePrime/jsonpath/path_states.go
new file mode 100644
index 0000000..b1e82de
--- /dev/null
+++ b/cli/vendor/github.com/NodePrime/jsonpath/path_states.go
@@ -0,0 +1,213 @@
+package jsonpath
+
+const (
+	pathError = iota
+	pathEOF
+
+	pathRoot
+	pathCurrent
+	pathKey
+	pathBracketLeft
+	pathBracketRight
+	pathIndex
+	pathOr
+	pathIndexRange
+	pathLength
+	pathWildcard
+	pathPeriod
+	pathValue
+	pathWhere
+	pathExpression
+)
+
+var pathTokenNames = map[int]string{
+	pathError: "ERROR",
+	pathEOF:   "EOF",
+
+	pathRoot:         "$",
+	pathCurrent:      "@",
+	pathKey:          "KEY",
+	pathBracketLeft:  "[",
+	pathBracketRight: "]",
+	pathIndex:        "INDEX",
+	pathOr:           "|",
+	pathIndexRange:   ":",
+	pathLength:       "LENGTH",
+	pathWildcard:     "*",
+	pathPeriod:       ".",
+	pathValue:        "+",
+	pathWhere:        "?",
+	pathExpression:   "EXPRESSION",
+}
+
+var PATH = lexPathStart
+
+func lexPathStart(l lexer, state *intStack) stateFn {
+	ignoreSpaceRun(l)
+	cur := l.take()
+	switch cur {
+	case '$':
+		l.emit(pathRoot)
+	case '@':
+		l.emit(pathCurrent)
+	default:
+		return l.errorf("Expected $ or @ at start of path instead of  %#U", cur)
+	}
+
+	return lexPathAfterKey
+}
+
+func lexPathAfterKey(l lexer, state *intStack) stateFn {
+	cur := l.take()
+	switch cur {
+	case '.':
+		l.emit(pathPeriod)
+		return lexKey
+	case '[':
+		l.emit(pathBracketLeft)
+		return lexPathBracketOpen
+	case '+':
+		l.emit(pathValue)
+		return lexPathAfterValue
+	case '?':
+		l.emit(pathWhere)
+		return lexPathExpression
+	case eof:
+		l.emit(pathEOF)
+	default:
+		return l.errorf("Unrecognized rune after path element %#U", cur)
+	}
+	return nil
+}
+
+func lexPathExpression(l lexer, state *intStack) stateFn {
+	cur := l.take()
+	if cur != '(' {
+		return l.errorf("Expected $ at start of path instead of  %#U", cur)
+	}
+
+	parenLeftCount := 1
+	for {
+		cur = l.take()
+		switch cur {
+		case '(':
+			parenLeftCount++
+		case ')':
+			parenLeftCount--
+		case eof:
+			return l.errorf("Unexpected EOF within expression")
+		}
+
+		if parenLeftCount == 0 {
+			break
+		}
+	}
+	l.emit(pathExpression)
+	return lexPathAfterKey
+}
+
+func lexPathBracketOpen(l lexer, state *intStack) stateFn {
+	switch l.peek() {
+	case '*':
+		l.take()
+		l.emit(pathWildcard)
+		return lexPathBracketClose
+	case '"':
+		l.takeString()
+		l.emit(pathKey)
+		return lexPathBracketClose
+	case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
+		l.take()
+		takeDigits(l)
+		l.emit(pathIndex)
+		return lexPathIndexRange
+	case eof:
+		l.emit(pathEOF)
+	}
+	return nil
+}
+
+func lexPathBracketClose(l lexer, state *intStack) stateFn {
+	cur := l.take()
+	if cur != ']' {
+		return l.errorf("Expected ] instead of  %#U", cur)
+	}
+	l.emit(pathBracketRight)
+	return lexPathAfterKey
+}
+
+func lexKey(l lexer, state *intStack) stateFn {
+	// TODO: Support globbing of keys
+	switch l.peek() {
+	case '*':
+		l.take()
+		l.emit(pathWildcard)
+		return lexPathAfterKey
+	case '"':
+		l.takeString()
+		l.emit(pathKey)
+		return lexPathAfterKey
+	case eof:
+		l.take()
+		l.emit(pathEOF)
+		return nil
+	default:
+		for {
+			v := l.peek()
+			if v == '.' || v == '[' || v == '+' || v == '?' || v == eof {
+				break
+			}
+			l.take()
+		}
+		l.emit(pathKey)
+		return lexPathAfterKey
+	}
+}
+
+func lexPathIndexRange(l lexer, state *intStack) stateFn {
+	// TODO: Expand supported operations
+	// Currently only supports single index or wildcard (1 or all)
+	cur := l.peek()
+	switch cur {
+	case ':':
+		l.take()
+		l.emit(pathIndexRange)
+		return lexPathIndexRangeSecond
+	case ']':
+		return lexPathBracketClose
+	default:
+		return l.errorf("Expected digit or ] instead of  %#U", cur)
+	}
+}
+
+func lexPathIndexRangeSecond(l lexer, state *intStack) stateFn {
+	cur := l.peek()
+	switch cur {
+	case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
+		takeDigits(l)
+		l.emit(pathIndex)
+		return lexPathBracketClose
+	case ']':
+		return lexPathBracketClose
+	default:
+		return l.errorf("Expected digit or ] instead of  %#U", cur)
+	}
+}
+
+func lexPathArrayClose(l lexer, state *intStack) stateFn {
+	cur := l.take()
+	if cur != ']' {
+		return l.errorf("Expected ] instead of  %#U", cur)
+	}
+	l.emit(pathBracketRight)
+	return lexPathAfterKey
+}
+
+func lexPathAfterValue(l lexer, state *intStack) stateFn {
+	cur := l.take()
+	if cur != eof {
+		return l.errorf("Expected EOF instead of %#U", cur)
+	}
+	l.emit(pathEOF)
+	return nil
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/799e9ccb/cli/vendor/github.com/NodePrime/jsonpath/path_states_test.go
----------------------------------------------------------------------
diff --git a/cli/vendor/github.com/NodePrime/jsonpath/path_states_test.go b/cli/vendor/github.com/NodePrime/jsonpath/path_states_test.go
new file mode 100644
index 0000000..42d5b41
--- /dev/null
+++ b/cli/vendor/github.com/NodePrime/jsonpath/path_states_test.go
@@ -0,0 +1,30 @@
+package jsonpath
+
+import (
+	"testing"
+
+	"github.com/stretchr/testify/assert"
+)
+
+var pathTests = []lexTest{
+	{"simple root node", `$.akey`, []int{pathRoot, pathPeriod, pathKey, pathEOF}},
+	{"simple current node", `@.akey`, []int{pathCurrent, pathPeriod, pathKey, pathEOF}},
+	{"simple root node w/ value", `$.akey+`, []int{pathRoot, pathPeriod, pathKey, pathValue, pathEOF}},
+	{"nested object", `$.akey.akey2`, []int{pathRoot, pathPeriod, pathKey, pathPeriod, pathKey, pathEOF}},
+	{"nested objects", `$.akey.akey2.akey3`, []int{pathRoot, pathPeriod, pathKey, pathPeriod, pathKey, pathPeriod, pathKey, pathEOF}},
+	{"quoted keys", `$.akey["akey2"].akey3`, []int{pathRoot, pathPeriod, pathKey, pathBracketLeft, pathKey, pathBracketRight, pathPeriod, pathKey, pathEOF}},
+	{"wildcard key", `$.akey.*.akey3`, []int{pathRoot, pathPeriod, pathKey, pathPeriod, pathWildcard, pathPeriod, pathKey, pathEOF}},
+	{"wildcard index", `$.akey[*]`, []int{pathRoot, pathPeriod, pathKey, pathBracketLeft, pathWildcard, pathBracketRight, pathEOF}},
+	{"key with where expression", `$.akey?(@.ten = 5)`, []int{pathRoot, pathPeriod, pathKey, pathWhere, pathExpression, pathEOF}},
+	{"bracket notation", `$["aKey"][*][32][23:42]`, []int{pathRoot, pathBracketLeft, pathKey, pathBracketRight, pathBracketLeft, pathWildcard, pathBracketRight, pathBracketLeft, pathIndex, pathBracketRight, pathBracketLeft, pathIndex, pathIndexRange, pathIndex, pathBracketRight, pathEOF}},
+}
+
+func TestValidPaths(t *testing.T) {
+	as := assert.New(t)
+	for _, test := range pathTests {
+		lexer := NewSliceLexer([]byte(test.input), PATH)
+		types := itemsToTypes(readerToArray(lexer))
+
+		as.EqualValues(types, test.tokenTypes, "Testing of %s: \nactual\n\t%+v\nexpected\n\t%v", test.name, typesDescription(types, pathTokenNames), typesDescription(test.tokenTypes, pathTokenNames))
+	}
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/799e9ccb/cli/vendor/github.com/NodePrime/jsonpath/path_test.go
----------------------------------------------------------------------
diff --git a/cli/vendor/github.com/NodePrime/jsonpath/path_test.go b/cli/vendor/github.com/NodePrime/jsonpath/path_test.go
new file mode 100644
index 0000000..ab7f2a2
--- /dev/null
+++ b/cli/vendor/github.com/NodePrime/jsonpath/path_test.go
@@ -0,0 +1,40 @@
+package jsonpath
+
+import (
+	"testing"
+
+	"github.com/stretchr/testify/assert"
+)
+
+type optest struct {
+	name     string
+	path     string
+	expected []int
+}
+
+var optests = []optest{
+	optest{"single key (period) ", `$.aKey`, []int{opTypeName}},
+	optest{"single key (bracket)", `$["aKey"]`, []int{opTypeName}},
+	optest{"single key (period) ", `$.*`, []int{opTypeNameWild}},
+	optest{"single index", `$[12]`, []int{opTypeIndex}},
+	optest{"single key", `$[23:45]`, []int{opTypeIndexRange}},
+	optest{"single key", `$[*]`, []int{opTypeIndexWild}},
+
+	optest{"double key", `$["aKey"]["bKey"]`, []int{opTypeName, opTypeName}},
+	optest{"double key", `$["aKey"].bKey`, []int{opTypeName, opTypeName}},
+}
+
+func TestQueryOperators(t *testing.T) {
+	as := assert.New(t)
+
+	for _, t := range optests {
+		path, err := parsePath(t.path)
+		as.NoError(err)
+
+		as.EqualValues(len(t.expected), len(path.operators))
+
+		for x, op := range t.expected {
+			as.EqualValues(pathTokenNames[op], pathTokenNames[path.operators[x].typ])
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/799e9ccb/cli/vendor/github.com/NodePrime/jsonpath/queue.go
----------------------------------------------------------------------
diff --git a/cli/vendor/github.com/NodePrime/jsonpath/queue.go b/cli/vendor/github.com/NodePrime/jsonpath/queue.go
new file mode 100644
index 0000000..67566b7
--- /dev/null
+++ b/cli/vendor/github.com/NodePrime/jsonpath/queue.go
@@ -0,0 +1,55 @@
+package jsonpath
+
+type Results struct {
+	nodes []*Result
+	head  int
+	tail  int
+	count int
+}
+
+func newResults() *Results {
+	return &Results{
+		nodes: make([]*Result, 3, 3),
+	}
+}
+
+func (q *Results) push(n *Result) {
+	if q.head == q.tail && q.count > 0 {
+		nodes := make([]*Result, len(q.nodes)*2, len(q.nodes)*2)
+		copy(nodes, q.nodes[q.head:])
+		copy(nodes[len(q.nodes)-q.head:], q.nodes[:q.head])
+		q.head = 0
+		q.tail = len(q.nodes)
+		q.nodes = nodes
+	}
+	q.nodes[q.tail] = n
+	q.tail = (q.tail + 1) % len(q.nodes)
+	q.count++
+}
+
+func (q *Results) Pop() *Result {
+	if q.count == 0 {
+		return nil
+	}
+	node := q.nodes[q.head]
+	q.head = (q.head + 1) % len(q.nodes)
+	q.count--
+	return node
+}
+
+func (q *Results) peek() *Result {
+	if q.count == 0 {
+		return nil
+	}
+	return q.nodes[q.head]
+}
+
+func (q *Results) len() int {
+	return q.count
+}
+
+func (q *Results) clear() {
+	q.head = 0
+	q.count = 0
+	q.tail = 0
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/799e9ccb/cli/vendor/github.com/NodePrime/jsonpath/result.go
----------------------------------------------------------------------
diff --git a/cli/vendor/github.com/NodePrime/jsonpath/result.go b/cli/vendor/github.com/NodePrime/jsonpath/result.go
new file mode 100644
index 0000000..8078ea9
--- /dev/null
+++ b/cli/vendor/github.com/NodePrime/jsonpath/result.go
@@ -0,0 +1,57 @@
+package jsonpath
+
+import (
+	"bytes"
+	"fmt"
+)
+
+const (
+	JsonObject = iota
+	JsonArray
+	JsonString
+	JsonNumber
+	JsonNull
+	JsonBool
+)
+
+type Result struct {
+	Keys  []interface{}
+	Value []byte
+	Type  int
+}
+
+func (r *Result) Pretty(showPath bool) string {
+	b := bytes.NewBufferString("")
+	printed := false
+	if showPath {
+		for _, k := range r.Keys {
+			switch v := k.(type) {
+			case int:
+				b.WriteString(fmt.Sprintf("%d", v))
+			default:
+				b.WriteString(fmt.Sprintf("%q", v))
+			}
+			b.WriteRune('\t')
+			printed = true
+		}
+	} else if r.Value == nil {
+		if len(r.Keys) > 0 {
+			printed = true
+			switch v := r.Keys[len(r.Keys)-1].(type) {
+			case int:
+				b.WriteString(fmt.Sprintf("%d", v))
+			default:
+				b.WriteString(fmt.Sprintf("%q", v))
+			}
+		}
+	}
+
+	if r.Value != nil {
+		printed = true
+		b.WriteString(fmt.Sprintf("%s", r.Value))
+	}
+	if printed {
+		b.WriteRune('\n')
+	}
+	return b.String()
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/799e9ccb/cli/vendor/github.com/NodePrime/jsonpath/run.go
----------------------------------------------------------------------
diff --git a/cli/vendor/github.com/NodePrime/jsonpath/run.go b/cli/vendor/github.com/NodePrime/jsonpath/run.go
new file mode 100644
index 0000000..e484fe5
--- /dev/null
+++ b/cli/vendor/github.com/NodePrime/jsonpath/run.go
@@ -0,0 +1,27 @@
+package jsonpath
+
+import "io"
+
+func EvalPathsInBytes(input []byte, paths []*Path) (*Eval, error) {
+	lexer := NewSliceLexer(input, JSON)
+	eval := newEvaluation(lexer, paths...)
+	return eval, nil
+}
+
+func EvalPathsInReader(r io.Reader, paths []*Path) (*Eval, error) {
+	lexer := NewReaderLexer(r, JSON)
+	eval := newEvaluation(lexer, paths...)
+	return eval, nil
+}
+
+func ParsePaths(pathStrings ...string) ([]*Path, error) {
+	paths := make([]*Path, len(pathStrings))
+	for x, p := range pathStrings {
+		path, err := parsePath(p)
+		if err != nil {
+			return nil, err
+		}
+		paths[x] = path
+	}
+	return paths, nil
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/799e9ccb/cli/vendor/github.com/NodePrime/jsonpath/stack.go
----------------------------------------------------------------------
diff --git a/cli/vendor/github.com/NodePrime/jsonpath/stack.go b/cli/vendor/github.com/NodePrime/jsonpath/stack.go
new file mode 100644
index 0000000..58818a4
--- /dev/null
+++ b/cli/vendor/github.com/NodePrime/jsonpath/stack.go
@@ -0,0 +1,148 @@
+package jsonpath
+
+// Integer Stack
+
+type intStack struct {
+	values []int
+}
+
+func newIntStack() *intStack {
+	return &intStack{
+		values: make([]int, 0, 100),
+	}
+}
+
+func (s *intStack) len() int {
+	return len(s.values)
+}
+
+func (s *intStack) push(r int) {
+	s.values = append(s.values, r)
+}
+
+func (s *intStack) pop() (int, bool) {
+	if s.len() == 0 {
+		return 0, false
+	}
+	v, _ := s.peek()
+	s.values = s.values[:len(s.values)-1]
+	return v, true
+}
+
+func (s *intStack) peek() (int, bool) {
+	if s.len() == 0 {
+		return 0, false
+	}
+	v := s.values[len(s.values)-1]
+	return v, true
+}
+
+func (s *intStack) clone() *intStack {
+	d := intStack{
+		values: make([]int, s.len()),
+	}
+	copy(d.values, s.values)
+	return &d
+}
+
+func (s *intStack) toArray() []int {
+	return s.values
+}
+
+// Result Stack
+
+type resultStack struct {
+	values []Result
+}
+
+func newResultStack() *resultStack {
+	return &resultStack{
+		values: make([]Result, 0),
+	}
+}
+
+func (s *resultStack) len() int {
+	return len(s.values)
+}
+
+func (s *resultStack) push(r Result) {
+	s.values = append(s.values, r)
+}
+
+func (s *resultStack) pop() (Result, bool) {
+	if s.len() == 0 {
+		return Result{}, false
+	}
+	v, _ := s.peek()
+	s.values = s.values[:len(s.values)-1]
+	return v, true
+}
+
+func (s *resultStack) peek() (Result, bool) {
+	if s.len() == 0 {
+		return Result{}, false
+	}
+	v := s.values[len(s.values)-1]
+	return v, true
+}
+
+func (s *resultStack) clone() *resultStack {
+	d := resultStack{
+		values: make([]Result, s.len()),
+	}
+	copy(d.values, s.values)
+	return &d
+}
+
+func (s *resultStack) toArray() []Result {
+	return s.values
+}
+
+// Interface Stack
+
+type stack struct {
+	values []interface{}
+}
+
+func newStack() *stack {
+	return &stack{
+		values: make([]interface{}, 0, 100),
+	}
+}
+
+func (s *stack) len() int {
+	return len(s.values)
+}
+
+func (s *stack) push(r interface{}) {
+	s.values = append(s.values, r)
+}
+
+func (s *stack) pop() (interface{}, bool) {
+	if s.len() == 0 {
+		return nil, false
+	}
+	v, _ := s.peek()
+	s.values = s.values[:len(s.values)-1]
+	return v, true
+}
+
+func (s *stack) peek() (interface{}, bool) {
+	if s.len() == 0 {
+		return nil, false
+	}
+	v := s.values[len(s.values)-1]
+	return v, true
+}
+
+func (s *stack) clone() *stack {
+	d := stack{
+		values: make([]interface{}, s.len()),
+	}
+	copy(d.values, s.values)
+	return &d
+}
+
+func (s *stack) toArray() []interface{} {
+	return s.values
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/799e9ccb/cli/vendor/github.com/NodePrime/jsonpath/stack_test.go
----------------------------------------------------------------------
diff --git a/cli/vendor/github.com/NodePrime/jsonpath/stack_test.go b/cli/vendor/github.com/NodePrime/jsonpath/stack_test.go
new file mode 100644
index 0000000..d1b1d2f
--- /dev/null
+++ b/cli/vendor/github.com/NodePrime/jsonpath/stack_test.go
@@ -0,0 +1,56 @@
+package jsonpath
+
+import (
+	"testing"
+
+	"github.com/stretchr/testify/assert"
+)
+
+func TestStackPush(t *testing.T) {
+	as := assert.New(t)
+	s := newIntStack()
+
+	s.push(5)
+	as.EqualValues(s.len(), 1)
+
+	s.push(12)
+	as.EqualValues(s.len(), 2)
+}
+
+func TestStackPop(t *testing.T) {
+	as := assert.New(t)
+	s := newIntStack()
+
+	s.push(99)
+	as.EqualValues(s.len(), 1)
+
+	v, ok := s.pop()
+	as.True(ok)
+	as.EqualValues(99, v)
+
+	as.EqualValues(s.len(), 0)
+}
+
+func TestStackPeek(t *testing.T) {
+	as := assert.New(t)
+	s := newIntStack()
+
+	s.push(99)
+	v, ok := s.peek()
+	as.True(ok)
+	as.EqualValues(99, v)
+
+	s.push(54)
+	v, ok = s.peek()
+	as.True(ok)
+	as.EqualValues(54, v)
+
+	s.pop()
+	v, ok = s.peek()
+	as.True(ok)
+	as.EqualValues(99, v)
+
+	s.pop()
+	_, ok = s.peek()
+	as.False(ok)
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/799e9ccb/cli/vendor/github.com/urfave/cli/.travis.yml
----------------------------------------------------------------------
diff --git a/cli/vendor/github.com/urfave/cli/.travis.yml b/cli/vendor/github.com/urfave/cli/.travis.yml
new file mode 100644
index 0000000..87ba52f
--- /dev/null
+++ b/cli/vendor/github.com/urfave/cli/.travis.yml
@@ -0,0 +1,19 @@
+language: go
+sudo: false
+
+go:
+- 1.0.3
+- 1.1.2
+- 1.2.2
+- 1.3.3
+- 1.4.2
+- 1.5.1
+- tip
+
+matrix:
+  allow_failures:
+    - go: tip
+
+script:
+- go vet ./...
+- go test -v ./...

http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/799e9ccb/cli/vendor/github.com/urfave/cli/LICENSE
----------------------------------------------------------------------
diff --git a/cli/vendor/github.com/urfave/cli/LICENSE b/cli/vendor/github.com/urfave/cli/LICENSE
new file mode 100644
index 0000000..5515ccf
--- /dev/null
+++ b/cli/vendor/github.com/urfave/cli/LICENSE
@@ -0,0 +1,21 @@
+Copyright (C) 2013 Jeremy Saenz
+All Rights Reserved.
+
+MIT LICENSE
+
+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.

http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/799e9ccb/cli/vendor/github.com/urfave/cli/README.md
----------------------------------------------------------------------
diff --git a/cli/vendor/github.com/urfave/cli/README.md b/cli/vendor/github.com/urfave/cli/README.md
new file mode 100644
index 0000000..ae0a4ca
--- /dev/null
+++ b/cli/vendor/github.com/urfave/cli/README.md
@@ -0,0 +1,352 @@
+[![Coverage](http://gocover.io/_badge/github.com/codegangsta/cli?0)](http://gocover.io/github.com/codegangsta/cli)
+[![Build Status](https://travis-ci.org/codegangsta/cli.svg?branch=master)](https://travis-ci.org/codegangsta/cli)
+[![GoDoc](https://godoc.org/github.com/codegangsta/cli?status.svg)](https://godoc.org/github.com/codegangsta/cli)
+
+# cli.go
+
+`cli.go` is simple, fast, and fun package for building command line apps in Go. The goal is to enable developers to write fast and distributable command line applications in an expressive way.
+
+## Overview
+
+Command line apps are usually so tiny that there is absolutely no reason why your code should *not* be self-documenting. Things like generating help text and parsing command flags/options should not hinder productivity when writing a command line app.
+
+**This is where `cli.go` comes into play.** `cli.go` makes command line programming fun, organized, and expressive!
+
+## Installation
+
+Make sure you have a working Go environment (go 1.1+ is *required*). [See the install instructions](http://golang.org/doc/install.html).
+
+To install `cli.go`, simply run:
+```
+$ go get github.com/codegangsta/cli
+```
+
+Make sure your `PATH` includes to the `$GOPATH/bin` directory so your commands can be easily used:
+```
+export PATH=$PATH:$GOPATH/bin
+```
+
+## Getting Started
+
+One of the philosophies behind `cli.go` is that an API should be playful and full of discovery. So a `cli.go` app can be as little as one line of code in `main()`. 
+
+``` go
+package main
+
+import (
+  "os"
+  "github.com/codegangsta/cli"
+)
+
+func main() {
+  cli.NewApp().Run(os.Args)
+}
+```
+
+This app will run and show help text, but is not very useful. Let's give an action to execute and some help documentation:
+
+``` go
+package main
+
+import (
+  "os"
+  "github.com/codegangsta/cli"
+)
+
+func main() {
+  app := cli.NewApp()
+  app.Name = "boom"
+  app.Usage = "make an explosive entrance"
+  app.Action = func(c *cli.Context) {
+    println("boom! I say!")
+  }
+  
+  app.Run(os.Args)
+}
+```
+
+Running this already gives you a ton of functionality, plus support for things like subcommands and flags, which are covered below.
+
+## Example
+
+Being a programmer can be a lonely job. Thankfully by the power of automation that is not the case! Let's create a greeter app to fend off our demons of loneliness!
+
+Start by creating a directory named `greet`, and within it, add a file, `greet.go` with the following code in it:
+
+``` go
+package main
+
+import (
+  "os"
+  "github.com/codegangsta/cli"
+)
+
+func main() {
+  app := cli.NewApp()
+  app.Name = "greet"
+  app.Usage = "fight the loneliness!"
+  app.Action = func(c *cli.Context) {
+    println("Hello friend!")
+  }
+
+  app.Run(os.Args)
+}
+```
+
+Install our command to the `$GOPATH/bin` directory:
+
+```
+$ go install
+```
+
+Finally run our new command:
+
+```
+$ greet
+Hello friend!
+```
+
+`cli.go` also generates neat help text:
+
+```
+$ greet help
+NAME:
+    greet - fight the loneliness!
+
+USAGE:
+    greet [global options] command [command options] [arguments...]
+
+VERSION:
+    0.0.0
+
+COMMANDS:
+    help, h  Shows a list of commands or help for one command
+
+GLOBAL OPTIONS
+    --version	Shows version information
+```
+
+### Arguments
+
+You can lookup arguments by calling the `Args` function on `cli.Context`.
+
+``` go
+...
+app.Action = func(c *cli.Context) {
+  println("Hello", c.Args()[0])
+}
+...
+```
+
+### Flags
+
+Setting and querying flags is simple.
+
+``` go
+...
+app.Flags = []cli.Flag {
+  cli.StringFlag{
+    Name: "lang",
+    Value: "english",
+    Usage: "language for the greeting",
+  },
+}
+app.Action = func(c *cli.Context) {
+  name := "someone"
+  if len(c.Args()) > 0 {
+    name = c.Args()[0]
+  }
+  if c.String("lang") == "spanish" {
+    println("Hola", name)
+  } else {
+    println("Hello", name)
+  }
+}
+...
+```
+
+You can also set a destination variable for a flag, to which the content will be scanned.
+
+``` go
+...
+var language string
+app.Flags = []cli.Flag {
+  cli.StringFlag{
+    Name:        "lang",
+    Value:       "english",
+    Usage:       "language for the greeting",
+    Destination: &language,
+  },
+}
+app.Action = func(c *cli.Context) {
+  name := "someone"
+  if len(c.Args()) > 0 {
+    name = c.Args()[0]
+  }
+  if language == "spanish" {
+    println("Hola", name)
+  } else {
+    println("Hello", name)
+  }
+}
+...
+```
+
+See full list of flags at http://godoc.org/github.com/codegangsta/cli
+
+#### Alternate Names
+
+You can set alternate (or short) names for flags by providing a comma-delimited list for the `Name`. e.g.
+
+``` go
+app.Flags = []cli.Flag {
+  cli.StringFlag{
+    Name: "lang, l",
+    Value: "english",
+    Usage: "language for the greeting",
+  },
+}
+```
+
+That flag can then be set with `--lang spanish` or `-l spanish`. Note that giving two different forms of the same flag in the same command invocation is an error.
+
+#### Values from the Environment
+
+You can also have the default value set from the environment via `EnvVar`.  e.g.
+
+``` go
+app.Flags = []cli.Flag {
+  cli.StringFlag{
+    Name: "lang, l",
+    Value: "english",
+    Usage: "language for the greeting",
+    EnvVar: "APP_LANG",
+  },
+}
+```
+
+The `EnvVar` may also be given as a comma-delimited "cascade", where the first environment variable that resolves is used as the default.
+
+``` go
+app.Flags = []cli.Flag {
+  cli.StringFlag{
+    Name: "lang, l",
+    Value: "english",
+    Usage: "language for the greeting",
+    EnvVar: "LEGACY_COMPAT_LANG,APP_LANG,LANG",
+  },
+}
+```
+
+### Subcommands
+
+Subcommands can be defined for a more git-like command line app.
+
+```go
+...
+app.Commands = []cli.Command{
+  {
+    Name:      "add",
+    Aliases:     []string{"a"},
+    Usage:     "add a task to the list",
+    Action: func(c *cli.Context) {
+      println("added task: ", c.Args().First())
+    },
+  },
+  {
+    Name:      "complete",
+    Aliases:     []string{"c"},
+    Usage:     "complete a task on the list",
+    Action: func(c *cli.Context) {
+      println("completed task: ", c.Args().First())
+    },
+  },
+  {
+    Name:      "template",
+    Aliases:     []string{"r"},
+    Usage:     "options for task templates",
+    Subcommands: []cli.Command{
+      {
+        Name:  "add",
+        Usage: "add a new template",
+        Action: func(c *cli.Context) {
+            println("new task template: ", c.Args().First())
+        },
+      },
+      {
+        Name:  "remove",
+        Usage: "remove an existing template",
+        Action: func(c *cli.Context) {
+          println("removed task template: ", c.Args().First())
+        },
+      },
+    },
+  },
+}
+...
+```
+
+### Bash Completion
+
+You can enable completion commands by setting the `EnableBashCompletion`
+flag on the `App` object.  By default, this setting will only auto-complete to
+show an app's subcommands, but you can write your own completion methods for
+the App or its subcommands.
+
+```go
+...
+var tasks = []string{"cook", "clean", "laundry", "eat", "sleep", "code"}
+app := cli.NewApp()
+app.EnableBashCompletion = true
+app.Commands = []cli.Command{
+  {
+    Name:  "complete",
+    Aliases: []string{"c"},
+    Usage: "complete a task on the list",
+    Action: func(c *cli.Context) {
+       println("completed task: ", c.Args().First())
+    },
+    BashComplete: func(c *cli.Context) {
+      // This will complete if no args are passed
+      if len(c.Args()) > 0 {
+        return
+      }
+      for _, t := range tasks {
+        fmt.Println(t)
+      }
+    },
+  }
+}
+...
+```
+
+#### To Enable
+
+Source the `autocomplete/bash_autocomplete` file in your `.bashrc` file while
+setting the `PROG` variable to the name of your program:
+
+`PROG=myprogram source /.../cli/autocomplete/bash_autocomplete`
+
+#### To Distribute
+
+Copy `autocomplete/bash_autocomplete` into `/etc/bash_completion.d/` and rename
+it to the name of the program you wish to add autocomplete support for (or
+automatically install it there if you are distributing a package). Don't forget
+to source the file to make it active in the current shell.
+
+```
+sudo cp src/bash_autocomplete /etc/bash_completion.d/<myprogram>
+source /etc/bash_completion.d/<myprogram>
+```
+
+Alternatively, you can just document that users should source the generic
+`autocomplete/bash_autocomplete` in their bash configuration with `$PROG` set
+to the name of their program (as above).
+
+## Contribution Guidelines
+
+Feel free to put up a pull request to fix a bug or maybe add a feature. I will give it a code review and make sure that it does not break backwards compatibility. If I or any other collaborators agree that it is in line with the vision of the project, we will work with you to get the code into a mergeable state and merge it into the master branch.
+
+If you have contributed something significant to the project, I will most likely add you as a collaborator. As a collaborator you are given the ability to merge others pull requests. It is very important that new code does not break existing code, so be careful about what code you do choose to merge. If you have any questions feel free to link @codegangsta to the issue in question and we can review it together.
+
+If you feel like you have contributed to the project but have not yet been added as a collaborator, I probably forgot to add you. Hit @codegangsta up over email and we will get it figured out.

http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/799e9ccb/cli/vendor/github.com/urfave/cli/app.go
----------------------------------------------------------------------
diff --git a/cli/vendor/github.com/urfave/cli/app.go b/cli/vendor/github.com/urfave/cli/app.go
new file mode 100644
index 0000000..1ea3fd0
--- /dev/null
+++ b/cli/vendor/github.com/urfave/cli/app.go
@@ -0,0 +1,349 @@
+package cli
+
+import (
+	"fmt"
+	"io"
+	"io/ioutil"
+	"os"
+	"path"
+	"time"
+)
+
+// App is the main structure of a cli application. It is recommended that
+// an app be created with the cli.NewApp() function
+type App struct {
+	// The name of the program. Defaults to path.Base(os.Args[0])
+	Name string
+	// Full name of command for help, defaults to Name
+	HelpName string
+	// Description of the program.
+	Usage string
+	// Text to override the USAGE section of help
+	UsageText string
+	// Description of the program argument format.
+	ArgsUsage string
+	// Version of the program
+	Version string
+	// List of commands to execute
+	Commands []Command
+	// List of flags to parse
+	Flags []Flag
+	// Boolean to enable bash completion commands
+	EnableBashCompletion bool
+	// Boolean to hide built-in help command
+	HideHelp bool
+	// Boolean to hide built-in version flag
+	HideVersion bool
+	// An action to execute when the bash-completion flag is set
+	BashComplete func(context *Context)
+	// An action to execute before any subcommands are run, but after the context is ready
+	// If a non-nil error is returned, no subcommands are run
+	Before func(context *Context) error
+	// An action to execute after any subcommands are run, but after the subcommand has finished
+	// It is run even if Action() panics
+	After func(context *Context) error
+	// The action to execute when no subcommands are specified
+	Action func(context *Context)
+	// Execute this function if the proper command cannot be found
+	CommandNotFound func(context *Context, command string)
+	// Execute this function, if an usage error occurs. This is useful for displaying customized usage error messages.
+	// This function is able to replace the original error messages.
+	// If this function is not set, the "Incorrect usage" is displayed and the execution is interrupted.
+	OnUsageError func(context *Context, err error, isSubcommand bool) error
+	// Compilation date
+	Compiled time.Time
+	// List of all authors who contributed
+	Authors []Author
+	// Copyright of the binary if any
+	Copyright string
+	// Name of Author (Note: Use App.Authors, this is deprecated)
+	Author string
+	// Email of Author (Note: Use App.Authors, this is deprecated)
+	Email string
+	// Writer writer to write output to
+	Writer io.Writer
+}
+
+// Tries to find out when this binary was compiled.
+// Returns the current time if it fails to find it.
+func compileTime() time.Time {
+	info, err := os.Stat(os.Args[0])
+	if err != nil {
+		return time.Now()
+	}
+	return info.ModTime()
+}
+
+// Creates a new cli Application with some reasonable defaults for Name, Usage, Version and Action.
+func NewApp() *App {
+	return &App{
+		Name:         path.Base(os.Args[0]),
+		HelpName:     path.Base(os.Args[0]),
+		Usage:        "A new cli application",
+		UsageText:    "",
+		Version:      "0.0.0",
+		BashComplete: DefaultAppComplete,
+		Action:       helpCommand.Action,
+		Compiled:     compileTime(),
+		Writer:       os.Stdout,
+	}
+}
+
+// Entry point to the cli app. Parses the arguments slice and routes to the proper flag/args combination
+func (a *App) Run(arguments []string) (err error) {
+	if a.Author != "" || a.Email != "" {
+		a.Authors = append(a.Authors, Author{Name: a.Author, Email: a.Email})
+	}
+
+	newCmds := []Command{}
+	for _, c := range a.Commands {
+		if c.HelpName == "" {
+			c.HelpName = fmt.Sprintf("%s %s", a.HelpName, c.Name)
+		}
+		newCmds = append(newCmds, c)
+	}
+	a.Commands = newCmds
+
+	// append help to commands
+	if a.Command(helpCommand.Name) == nil && !a.HideHelp {
+		a.Commands = append(a.Commands, helpCommand)
+		if (HelpFlag != BoolFlag{}) {
+			a.appendFlag(HelpFlag)
+		}
+	}
+
+	//append version/help flags
+	if a.EnableBashCompletion {
+		a.appendFlag(BashCompletionFlag)
+	}
+
+	if !a.HideVersion {
+		a.appendFlag(VersionFlag)
+	}
+
+	// parse flags
+	set := flagSet(a.Name, a.Flags)
+	set.SetOutput(ioutil.Discard)
+	err = set.Parse(arguments[1:])
+	nerr := normalizeFlags(a.Flags, set)
+	context := NewContext(a, set, nil)
+	if nerr != nil {
+		fmt.Fprintln(a.Writer, nerr)
+		ShowAppHelp(context)
+		return nerr
+	}
+
+	if checkCompletions(context) {
+		return nil
+	}
+
+	if err != nil {
+		if a.OnUsageError != nil {
+			err := a.OnUsageError(context, err, false)
+			return err
+		} else {
+			fmt.Fprintf(a.Writer, "%s\n\n", "Incorrect Usage.")
+			ShowAppHelp(context)
+			return err
+		}
+	}
+
+	if !a.HideHelp && checkHelp(context) {
+		ShowAppHelp(context)
+		return nil
+	}
+
+	if !a.HideVersion && checkVersion(context) {
+		ShowVersion(context)
+		return nil
+	}
+
+	if a.After != nil {
+		defer func() {
+			if afterErr := a.After(context); afterErr != nil {
+				if err != nil {
+					err = NewMultiError(err, afterErr)
+				} else {
+					err = afterErr
+				}
+			}
+		}()
+	}
+
+	if a.Before != nil {
+		err = a.Before(context)
+		if err != nil {
+			fmt.Fprintf(a.Writer, "%v\n\n", err)
+			ShowAppHelp(context)
+			return err
+		}
+	}
+
+	args := context.Args()
+	if args.Present() {
+		name := args.First()
+		c := a.Command(name)
+		if c != nil {
+			return c.Run(context)
+		}
+	}
+
+	// Run default Action
+	a.Action(context)
+	return nil
+}
+
+// Another entry point to the cli app, takes care of passing arguments and error handling
+func (a *App) RunAndExitOnError() {
+	if err := a.Run(os.Args); err != nil {
+		fmt.Fprintln(os.Stderr, err)
+		os.Exit(1)
+	}
+}
+
+// Invokes the subcommand given the context, parses ctx.Args() to generate command-specific flags
+func (a *App) RunAsSubcommand(ctx *Context) (err error) {
+	// append help to commands
+	if len(a.Commands) > 0 {
+		if a.Command(helpCommand.Name) == nil && !a.HideHelp {
+			a.Commands = append(a.Commands, helpCommand)
+			if (HelpFlag != BoolFlag{}) {
+				a.appendFlag(HelpFlag)
+			}
+		}
+	}
+
+	newCmds := []Command{}
+	for _, c := range a.Commands {
+		if c.HelpName == "" {
+			c.HelpName = fmt.Sprintf("%s %s", a.HelpName, c.Name)
+		}
+		newCmds = append(newCmds, c)
+	}
+	a.Commands = newCmds
+
+	// append flags
+	if a.EnableBashCompletion {
+		a.appendFlag(BashCompletionFlag)
+	}
+
+	// parse flags
+	set := flagSet(a.Name, a.Flags)
+	set.SetOutput(ioutil.Discard)
+	err = set.Parse(ctx.Args().Tail())
+	nerr := normalizeFlags(a.Flags, set)
+	context := NewContext(a, set, ctx)
+
+	if nerr != nil {
+		fmt.Fprintln(a.Writer, nerr)
+		fmt.Fprintln(a.Writer)
+		if len(a.Commands) > 0 {
+			ShowSubcommandHelp(context)
+		} else {
+			ShowCommandHelp(ctx, context.Args().First())
+		}
+		return nerr
+	}
+
+	if checkCompletions(context) {
+		return nil
+	}
+
+	if err != nil {
+		if a.OnUsageError != nil {
+			err = a.OnUsageError(context, err, true)
+			return err
+		} else {
+			fmt.Fprintf(a.Writer, "%s\n\n", "Incorrect Usage.")
+			ShowSubcommandHelp(context)
+			return err
+		}
+	}
+
+	if len(a.Commands) > 0 {
+		if checkSubcommandHelp(context) {
+			return nil
+		}
+	} else {
+		if checkCommandHelp(ctx, context.Args().First()) {
+			return nil
+		}
+	}
+
+	if a.After != nil {
+		defer func() {
+			afterErr := a.After(context)
+			if afterErr != nil {
+				if err != nil {
+					err = NewMultiError(err, afterErr)
+				} else {
+					err = afterErr
+				}
+			}
+		}()
+	}
+
+	if a.Before != nil {
+		err := a.Before(context)
+		if err != nil {
+			return err
+		}
+	}
+
+	args := context.Args()
+	if args.Present() {
+		name := args.First()
+		c := a.Command(name)
+		if c != nil {
+			return c.Run(context)
+		}
+	}
+
+	// Run default Action
+	a.Action(context)
+
+	return nil
+}
+
+// Returns the named command on App. Returns nil if the command does not exist
+func (a *App) Command(name string) *Command {
+	for _, c := range a.Commands {
+		if c.HasName(name) {
+			return &c
+		}
+	}
+
+	return nil
+}
+
+func (a *App) hasFlag(flag Flag) bool {
+	for _, f := range a.Flags {
+		if flag == f {
+			return true
+		}
+	}
+
+	return false
+}
+
+func (a *App) appendFlag(flag Flag) {
+	if !a.hasFlag(flag) {
+		a.Flags = append(a.Flags, flag)
+	}
+}
+
+// Author represents someone who has contributed to a cli project.
+type Author struct {
+	Name  string // The Authors name
+	Email string // The Authors email
+}
+
+// String makes Author comply to the Stringer interface, to allow an easy print in the templating process
+func (a Author) String() string {
+	e := ""
+	if a.Email != "" {
+		e = "<" + a.Email + "> "
+	}
+
+	return fmt.Sprintf("%v %v", a.Name, e)
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/799e9ccb/cli/vendor/github.com/urfave/cli/app_test.go
----------------------------------------------------------------------
diff --git a/cli/vendor/github.com/urfave/cli/app_test.go b/cli/vendor/github.com/urfave/cli/app_test.go
new file mode 100644
index 0000000..7feaf1f
--- /dev/null
+++ b/cli/vendor/github.com/urfave/cli/app_test.go
@@ -0,0 +1,1047 @@
+package cli
+
+import (
+	"bytes"
+	"errors"
+	"flag"
+	"fmt"
+	"io"
+	"io/ioutil"
+	"os"
+	"strings"
+	"testing"
+)
+
+func ExampleApp_Run() {
+	// set args for examples sake
+	os.Args = []string{"greet", "--name", "Jeremy"}
+
+	app := NewApp()
+	app.Name = "greet"
+	app.Flags = []Flag{
+		StringFlag{Name: "name", Value: "bob", Usage: "a name to say"},
+	}
+	app.Action = func(c *Context) {
+		fmt.Printf("Hello %v\n", c.String("name"))
+	}
+	app.UsageText = "app [first_arg] [second_arg]"
+	app.Author = "Harrison"
+	app.Email = "harrison@lolwut.com"
+	app.Authors = []Author{Author{Name: "Oliver Allen", Email: "oliver@toyshop.com"}}
+	app.Run(os.Args)
+	// Output:
+	// Hello Jeremy
+}
+
+func ExampleApp_Run_subcommand() {
+	// set args for examples sake
+	os.Args = []string{"say", "hi", "english", "--name", "Jeremy"}
+	app := NewApp()
+	app.Name = "say"
+	app.Commands = []Command{
+		{
+			Name:        "hello",
+			Aliases:     []string{"hi"},
+			Usage:       "use it to see a description",
+			Description: "This is how we describe hello the function",
+			Subcommands: []Command{
+				{
+					Name:        "english",
+					Aliases:     []string{"en"},
+					Usage:       "sends a greeting in english",
+					Description: "greets someone in english",
+					Flags: []Flag{
+						StringFlag{
+							Name:  "name",
+							Value: "Bob",
+							Usage: "Name of the person to greet",
+						},
+					},
+					Action: func(c *Context) {
+						fmt.Println("Hello,", c.String("name"))
+					},
+				},
+			},
+		},
+	}
+
+	app.Run(os.Args)
+	// Output:
+	// Hello, Jeremy
+}
+
+func ExampleApp_Run_help() {
+	// set args for examples sake
+	os.Args = []string{"greet", "h", "describeit"}
+
+	app := NewApp()
+	app.Name = "greet"
+	app.Flags = []Flag{
+		StringFlag{Name: "name", Value: "bob", Usage: "a name to say"},
+	}
+	app.Commands = []Command{
+		{
+			Name:        "describeit",
+			Aliases:     []string{"d"},
+			Usage:       "use it to see a description",
+			Description: "This is how we describe describeit the function",
+			Action: func(c *Context) {
+				fmt.Printf("i like to describe things")
+			},
+		},
+	}
+	app.Run(os.Args)
+	// Output:
+	// NAME:
+	//    greet describeit - use it to see a description
+	//
+	// USAGE:
+	//    greet describeit [arguments...]
+	//
+	// DESCRIPTION:
+	//    This is how we describe describeit the function
+}
+
+func ExampleApp_Run_bashComplete() {
+	// set args for examples sake
+	os.Args = []string{"greet", "--generate-bash-completion"}
+
+	app := NewApp()
+	app.Name = "greet"
+	app.EnableBashCompletion = true
+	app.Commands = []Command{
+		{
+			Name:        "describeit",
+			Aliases:     []string{"d"},
+			Usage:       "use it to see a description",
+			Description: "This is how we describe describeit the function",
+			Action: func(c *Context) {
+				fmt.Printf("i like to describe things")
+			},
+		}, {
+			Name:        "next",
+			Usage:       "next example",
+			Description: "more stuff to see when generating bash completion",
+			Action: func(c *Context) {
+				fmt.Printf("the next example")
+			},
+		},
+	}
+
+	app.Run(os.Args)
+	// Output:
+	// describeit
+	// d
+	// next
+	// help
+	// h
+}
+
+func TestApp_Run(t *testing.T) {
+	s := ""
+
+	app := NewApp()
+	app.Action = func(c *Context) {
+		s = s + c.Args().First()
+	}
+
+	err := app.Run([]string{"command", "foo"})
+	expect(t, err, nil)
+	err = app.Run([]string{"command", "bar"})
+	expect(t, err, nil)
+	expect(t, s, "foobar")
+}
+
+var commandAppTests = []struct {
+	name     string
+	expected bool
+}{
+	{"foobar", true},
+	{"batbaz", true},
+	{"b", true},
+	{"f", true},
+	{"bat", false},
+	{"nothing", false},
+}
+
+func TestApp_Command(t *testing.T) {
+	app := NewApp()
+	fooCommand := Command{Name: "foobar", Aliases: []string{"f"}}
+	batCommand := Command{Name: "batbaz", Aliases: []string{"b"}}
+	app.Commands = []Command{
+		fooCommand,
+		batCommand,
+	}
+
+	for _, test := range commandAppTests {
+		expect(t, app.Command(test.name) != nil, test.expected)
+	}
+}
+
+func TestApp_CommandWithArgBeforeFlags(t *testing.T) {
+	var parsedOption, firstArg string
+
+	app := NewApp()
+	command := Command{
+		Name: "cmd",
+		Flags: []Flag{
+			StringFlag{Name: "option", Value: "", Usage: "some option"},
+		},
+		Action: func(c *Context) {
+			parsedOption = c.String("option")
+			firstArg = c.Args().First()
+		},
+	}
+	app.Commands = []Command{command}
+
+	app.Run([]string{"", "cmd", "my-arg", "--option", "my-option"})
+
+	expect(t, parsedOption, "my-option")
+	expect(t, firstArg, "my-arg")
+}
+
+func TestApp_RunAsSubcommandParseFlags(t *testing.T) {
+	var context *Context
+
+	a := NewApp()
+	a.Commands = []Command{
+		{
+			Name: "foo",
+			Action: func(c *Context) {
+				context = c
+			},
+			Flags: []Flag{
+				StringFlag{
+					Name:  "lang",
+					Value: "english",
+					Usage: "language for the greeting",
+				},
+			},
+			Before: func(_ *Context) error { return nil },
+		},
+	}
+	a.Run([]string{"", "foo", "--lang", "spanish", "abcd"})
+
+	expect(t, context.Args().Get(0), "abcd")
+	expect(t, context.String("lang"), "spanish")
+}
+
+func TestApp_CommandWithFlagBeforeTerminator(t *testing.T) {
+	var parsedOption string
+	var args []string
+
+	app := NewApp()
+	command := Command{
+		Name: "cmd",
+		Flags: []Flag{
+			StringFlag{Name: "option", Value: "", Usage: "some option"},
+		},
+		Action: func(c *Context) {
+			parsedOption = c.String("option")
+			args = c.Args()
+		},
+	}
+	app.Commands = []Command{command}
+
+	app.Run([]string{"", "cmd", "my-arg", "--option", "my-option", "--", "--notARealFlag"})
+
+	expect(t, parsedOption, "my-option")
+	expect(t, args[0], "my-arg")
+	expect(t, args[1], "--")
+	expect(t, args[2], "--notARealFlag")
+}
+
+func TestApp_CommandWithDash(t *testing.T) {
+	var args []string
+
+	app := NewApp()
+	command := Command{
+		Name: "cmd",
+		Action: func(c *Context) {
+			args = c.Args()
+		},
+	}
+	app.Commands = []Command{command}
+
+	app.Run([]string{"", "cmd", "my-arg", "-"})
+
+	expect(t, args[0], "my-arg")
+	expect(t, args[1], "-")
+}
+
+func TestApp_CommandWithNoFlagBeforeTerminator(t *testing.T) {
+	var args []string
+
+	app := NewApp()
+	command := Command{
+		Name: "cmd",
+		Action: func(c *Context) {
+			args = c.Args()
+		},
+	}
+	app.Commands = []Command{command}
+
+	app.Run([]string{"", "cmd", "my-arg", "--", "notAFlagAtAll"})
+
+	expect(t, args[0], "my-arg")
+	expect(t, args[1], "--")
+	expect(t, args[2], "notAFlagAtAll")
+}
+
+func TestApp_Float64Flag(t *testing.T) {
+	var meters float64
+
+	app := NewApp()
+	app.Flags = []Flag{
+		Float64Flag{Name: "height", Value: 1.5, Usage: "Set the height, in meters"},
+	}
+	app.Action = func(c *Context) {
+		meters = c.Float64("height")
+	}
+
+	app.Run([]string{"", "--height", "1.93"})
+	expect(t, meters, 1.93)
+}
+
+func TestApp_ParseSliceFlags(t *testing.T) {
+	var parsedOption, firstArg string
+	var parsedIntSlice []int
+	var parsedStringSlice []string
+
+	app := NewApp()
+	command := Command{
+		Name: "cmd",
+		Flags: []Flag{
+			IntSliceFlag{Name: "p", Value: &IntSlice{}, Usage: "set one or more ip addr"},
+			StringSliceFlag{Name: "ip", Value: &StringSlice{}, Usage: "set one or more ports to open"},
+		},
+		Action: func(c *Context) {
+			parsedIntSlice = c.IntSlice("p")
+			parsedStringSlice = c.StringSlice("ip")
+			parsedOption = c.String("option")
+			firstArg = c.Args().First()
+		},
+	}
+	app.Commands = []Command{command}
+
+	app.Run([]string{"", "cmd", "my-arg", "-p", "22", "-p", "80", "-ip", "8.8.8.8", "-ip", "8.8.4.4"})
+
+	IntsEquals := func(a, b []int) bool {
+		if len(a) != len(b) {
+			return false
+		}
+		for i, v := range a {
+			if v != b[i] {
+				return false
+			}
+		}
+		return true
+	}
+
+	StrsEquals := func(a, b []string) bool {
+		if len(a) != len(b) {
+			return false
+		}
+		for i, v := range a {
+			if v != b[i] {
+				return false
+			}
+		}
+		return true
+	}
+	var expectedIntSlice = []int{22, 80}
+	var expectedStringSlice = []string{"8.8.8.8", "8.8.4.4"}
+
+	if !IntsEquals(parsedIntSlice, expectedIntSlice) {
+		t.Errorf("%v does not match %v", parsedIntSlice, expectedIntSlice)
+	}
+
+	if !StrsEquals(parsedStringSlice, expectedStringSlice) {
+		t.Errorf("%v does not match %v", parsedStringSlice, expectedStringSlice)
+	}
+}
+
+func TestApp_ParseSliceFlagsWithMissingValue(t *testing.T) {
+	var parsedIntSlice []int
+	var parsedStringSlice []string
+
+	app := NewApp()
+	command := Command{
+		Name: "cmd",
+		Flags: []Flag{
+			IntSliceFlag{Name: "a", Usage: "set numbers"},
+			StringSliceFlag{Name: "str", Usage: "set strings"},
+		},
+		Action: func(c *Context) {
+			parsedIntSlice = c.IntSlice("a")
+			parsedStringSlice = c.StringSlice("str")
+		},
+	}
+	app.Commands = []Command{command}
+
+	app.Run([]string{"", "cmd", "my-arg", "-a", "2", "-str", "A"})
+
+	var expectedIntSlice = []int{2}
+	var expectedStringSlice = []string{"A"}
+
+	if parsedIntSlice[0] != expectedIntSlice[0] {
+		t.Errorf("%v does not match %v", parsedIntSlice[0], expectedIntSlice[0])
+	}
+
+	if parsedStringSlice[0] != expectedStringSlice[0] {
+		t.Errorf("%v does not match %v", parsedIntSlice[0], expectedIntSlice[0])
+	}
+}
+
+func TestApp_DefaultStdout(t *testing.T) {
+	app := NewApp()
+
+	if app.Writer != os.Stdout {
+		t.Error("Default output writer not set.")
+	}
+}
+
+type mockWriter struct {
+	written []byte
+}
+
+func (fw *mockWriter) Write(p []byte) (n int, err error) {
+	if fw.written == nil {
+		fw.written = p
+	} else {
+		fw.written = append(fw.written, p...)
+	}
+
+	return len(p), nil
+}
+
+func (fw *mockWriter) GetWritten() (b []byte) {
+	return fw.written
+}
+
+func TestApp_SetStdout(t *testing.T) {
+	w := &mockWriter{}
+
+	app := NewApp()
+	app.Name = "test"
+	app.Writer = w
+
+	err := app.Run([]string{"help"})
+
+	if err != nil {
+		t.Fatalf("Run error: %s", err)
+	}
+
+	if len(w.written) == 0 {
+		t.Error("App did not write output to desired writer.")
+	}
+}
+
+func TestApp_BeforeFunc(t *testing.T) {
+	beforeRun, subcommandRun := false, false
+	beforeError := fmt.Errorf("fail")
+	var err error
+
+	app := NewApp()
+
+	app.Before = func(c *Context) error {
+		beforeRun = true
+		s := c.String("opt")
+		if s == "fail" {
+			return beforeError
+		}
+
+		return nil
+	}
+
+	app.Commands = []Command{
+		Command{
+			Name: "sub",
+			Action: func(c *Context) {
+				subcommandRun = true
+			},
+		},
+	}
+
+	app.Flags = []Flag{
+		StringFlag{Name: "opt"},
+	}
+
+	// run with the Before() func succeeding
+	err = app.Run([]string{"command", "--opt", "succeed", "sub"})
+
+	if err != nil {
+		t.Fatalf("Run error: %s", err)
+	}
+
+	if beforeRun == false {
+		t.Errorf("Before() not executed when expected")
+	}
+
+	if subcommandRun == false {
+		t.Errorf("Subcommand not executed when expected")
+	}
+
+	// reset
+	beforeRun, subcommandRun = false, false
+
+	// run with the Before() func failing
+	err = app.Run([]string{"command", "--opt", "fail", "sub"})
+
+	// should be the same error produced by the Before func
+	if err != beforeError {
+		t.Errorf("Run error expected, but not received")
+	}
+
+	if beforeRun == false {
+		t.Errorf("Before() not executed when expected")
+	}
+
+	if subcommandRun == true {
+		t.Errorf("Subcommand executed when NOT expected")
+	}
+
+}
+
+func TestApp_AfterFunc(t *testing.T) {
+	afterRun, subcommandRun := false, false
+	afterError := fmt.Errorf("fail")
+	var err error
+
+	app := NewApp()
+
+	app.After = func(c *Context) error {
+		afterRun = true
+		s := c.String("opt")
+		if s == "fail" {
+			return afterError
+		}
+
+		return nil
+	}
+
+	app.Commands = []Command{
+		Command{
+			Name: "sub",
+			Action: func(c *Context) {
+				subcommandRun = true
+			},
+		},
+	}
+
+	app.Flags = []Flag{
+		StringFlag{Name: "opt"},
+	}
+
+	// run with the After() func succeeding
+	err = app.Run([]string{"command", "--opt", "succeed", "sub"})
+
+	if err != nil {
+		t.Fatalf("Run error: %s", err)
+	}
+
+	if afterRun == false {
+		t.Errorf("After() not executed when expected")
+	}
+
+	if subcommandRun == false {
+		t.Errorf("Subcommand not executed when expected")
+	}
+
+	// reset
+	afterRun, subcommandRun = false, false
+
+	// run with the Before() func failing
+	err = app.Run([]string{"command", "--opt", "fail", "sub"})
+
+	// should be the same error produced by the Before func
+	if err != afterError {
+		t.Errorf("Run error expected, but not received")
+	}
+
+	if afterRun == false {
+		t.Errorf("After() not executed when expected")
+	}
+
+	if subcommandRun == false {
+		t.Errorf("Subcommand not executed when expected")
+	}
+}
+
+func TestAppNoHelpFlag(t *testing.T) {
+	oldFlag := HelpFlag
+	defer func() {
+		HelpFlag = oldFlag
+	}()
+
+	HelpFlag = BoolFlag{}
+
+	app := NewApp()
+	app.Writer = ioutil.Discard
+	err := app.Run([]string{"test", "-h"})
+
+	if err != flag.ErrHelp {
+		t.Errorf("expected error about missing help flag, but got: %s (%T)", err, err)
+	}
+}
+
+func TestAppHelpPrinter(t *testing.T) {
+	oldPrinter := HelpPrinter
+	defer func() {
+		HelpPrinter = oldPrinter
+	}()
+
+	var wasCalled = false
+	HelpPrinter = func(w io.Writer, template string, data interface{}) {
+		wasCalled = true
+	}
+
+	app := NewApp()
+	app.Run([]string{"-h"})
+
+	if wasCalled == false {
+		t.Errorf("Help printer expected to be called, but was not")
+	}
+}
+
+func TestAppVersionPrinter(t *testing.T) {
+	oldPrinter := VersionPrinter
+	defer func() {
+		VersionPrinter = oldPrinter
+	}()
+
+	var wasCalled = false
+	VersionPrinter = func(c *Context) {
+		wasCalled = true
+	}
+
+	app := NewApp()
+	ctx := NewContext(app, nil, nil)
+	ShowVersion(ctx)
+
+	if wasCalled == false {
+		t.Errorf("Version printer expected to be called, but was not")
+	}
+}
+
+func TestAppCommandNotFound(t *testing.T) {
+	beforeRun, subcommandRun := false, false
+	app := NewApp()
+
+	app.CommandNotFound = func(c *Context, command string) {
+		beforeRun = true
+	}
+
+	app.Commands = []Command{
+		Command{
+			Name: "bar",
+			Action: func(c *Context) {
+				subcommandRun = true
+			},
+		},
+	}
+
+	app.Run([]string{"command", "foo"})
+
+	expect(t, beforeRun, true)
+	expect(t, subcommandRun, false)
+}
+
+func TestGlobalFlag(t *testing.T) {
+	var globalFlag string
+	var globalFlagSet bool
+	app := NewApp()
+	app.Flags = []Flag{
+		StringFlag{Name: "global, g", Usage: "global"},
+	}
+	app.Action = func(c *Context) {
+		globalFlag = c.GlobalString("global")
+		globalFlagSet = c.GlobalIsSet("global")
+	}
+	app.Run([]string{"command", "-g", "foo"})
+	expect(t, globalFlag, "foo")
+	expect(t, globalFlagSet, true)
+
+}
+
+func TestGlobalFlagsInSubcommands(t *testing.T) {
+	subcommandRun := false
+	parentFlag := false
+	app := NewApp()
+
+	app.Flags = []Flag{
+		BoolFlag{Name: "debug, d", Usage: "Enable debugging"},
+	}
+
+	app.Commands = []Command{
+		Command{
+			Name: "foo",
+			Flags: []Flag{
+				BoolFlag{Name: "parent, p", Usage: "Parent flag"},
+			},
+			Subcommands: []Command{
+				{
+					Name: "bar",
+					Action: func(c *Context) {
+						if c.GlobalBool("debug") {
+							subcommandRun = true
+						}
+						if c.GlobalBool("parent") {
+							parentFlag = true
+						}
+					},
+				},
+			},
+		},
+	}
+
+	app.Run([]string{"command", "-d", "foo", "-p", "bar"})
+
+	expect(t, subcommandRun, true)
+	expect(t, parentFlag, true)
+}
+
+func TestApp_Run_CommandWithSubcommandHasHelpTopic(t *testing.T) {
+	var subcommandHelpTopics = [][]string{
+		{"command", "foo", "--help"},
+		{"command", "foo", "-h"},
+		{"command", "foo", "help"},
+	}
+
+	for _, flagSet := range subcommandHelpTopics {
+		t.Logf("==> checking with flags %v", flagSet)
+
+		app := NewApp()
+		buf := new(bytes.Buffer)
+		app.Writer = buf
+
+		subCmdBar := Command{
+			Name:  "bar",
+			Usage: "does bar things",
+		}
+		subCmdBaz := Command{
+			Name:  "baz",
+			Usage: "does baz things",
+		}
+		cmd := Command{
+			Name:        "foo",
+			Description: "descriptive wall of text about how it does foo things",
+			Subcommands: []Command{subCmdBar, subCmdBaz},
+		}
+
+		app.Commands = []Command{cmd}
+		err := app.Run(flagSet)
+
+		if err != nil {
+			t.Error(err)
+		}
+
+		output := buf.String()
+		t.Logf("output: %q\n", buf.Bytes())
+
+		if strings.Contains(output, "No help topic for") {
+			t.Errorf("expect a help topic, got none: \n%q", output)
+		}
+
+		for _, shouldContain := range []string{
+			cmd.Name, cmd.Description,
+			subCmdBar.Name, subCmdBar.Usage,
+			subCmdBaz.Name, subCmdBaz.Usage,
+		} {
+			if !strings.Contains(output, shouldContain) {
+				t.Errorf("want help to contain %q, did not: \n%q", shouldContain, output)
+			}
+		}
+	}
+}
+
+func TestApp_Run_SubcommandFullPath(t *testing.T) {
+	app := NewApp()
+	buf := new(bytes.Buffer)
+	app.Writer = buf
+	app.Name = "command"
+	subCmd := Command{
+		Name:  "bar",
+		Usage: "does bar things",
+	}
+	cmd := Command{
+		Name:        "foo",
+		Description: "foo commands",
+		Subcommands: []Command{subCmd},
+	}
+	app.Commands = []Command{cmd}
+
+	err := app.Run([]string{"command", "foo", "bar", "--help"})
+	if err != nil {
+		t.Error(err)
+	}
+
+	output := buf.String()
+	if !strings.Contains(output, "command foo bar - does bar things") {
+		t.Errorf("expected full path to subcommand: %s", output)
+	}
+	if !strings.Contains(output, "command foo bar [arguments...]") {
+		t.Errorf("expected full path to subcommand: %s", output)
+	}
+}
+
+func TestApp_Run_SubcommandHelpName(t *testing.T) {
+	app := NewApp()
+	buf := new(bytes.Buffer)
+	app.Writer = buf
+	app.Name = "command"
+	subCmd := Command{
+		Name:     "bar",
+		HelpName: "custom",
+		Usage:    "does bar things",
+	}
+	cmd := Command{
+		Name:        "foo",
+		Description: "foo commands",
+		Subcommands: []Command{subCmd},
+	}
+	app.Commands = []Command{cmd}
+
+	err := app.Run([]string{"command", "foo", "bar", "--help"})
+	if err != nil {
+		t.Error(err)
+	}
+
+	output := buf.String()
+	if !strings.Contains(output, "custom - does bar things") {
+		t.Errorf("expected HelpName for subcommand: %s", output)
+	}
+	if !strings.Contains(output, "custom [arguments...]") {
+		t.Errorf("expected HelpName to subcommand: %s", output)
+	}
+}
+
+func TestApp_Run_CommandHelpName(t *testing.T) {
+	app := NewApp()
+	buf := new(bytes.Buffer)
+	app.Writer = buf
+	app.Name = "command"
+	subCmd := Command{
+		Name:  "bar",
+		Usage: "does bar things",
+	}
+	cmd := Command{
+		Name:        "foo",
+		HelpName:    "custom",
+		Description: "foo commands",
+		Subcommands: []Command{subCmd},
+	}
+	app.Commands = []Command{cmd}
+
+	err := app.Run([]string{"command", "foo", "bar", "--help"})
+	if err != nil {
+		t.Error(err)
+	}
+
+	output := buf.String()
+	if !strings.Contains(output, "command foo bar - does bar things") {
+		t.Errorf("expected full path to subcommand: %s", output)
+	}
+	if !strings.Contains(output, "command foo bar [arguments...]") {
+		t.Errorf("expected full path to subcommand: %s", output)
+	}
+}
+
+func TestApp_Run_CommandSubcommandHelpName(t *testing.T) {
+	app := NewApp()
+	buf := new(bytes.Buffer)
+	app.Writer = buf
+	app.Name = "base"
+	subCmd := Command{
+		Name:     "bar",
+		HelpName: "custom",
+		Usage:    "does bar things",
+	}
+	cmd := Command{
+		Name:        "foo",
+		Description: "foo commands",
+		Subcommands: []Command{subCmd},
+	}
+	app.Commands = []Command{cmd}
+
+	err := app.Run([]string{"command", "foo", "--help"})
+	if err != nil {
+		t.Error(err)
+	}
+
+	output := buf.String()
+	if !strings.Contains(output, "base foo - foo commands") {
+		t.Errorf("expected full path to subcommand: %s", output)
+	}
+	if !strings.Contains(output, "base foo command [command options] [arguments...]") {
+		t.Errorf("expected full path to subcommand: %s", output)
+	}
+}
+
+func TestApp_Run_Help(t *testing.T) {
+	var helpArguments = [][]string{{"boom", "--help"}, {"boom", "-h"}, {"boom", "help"}}
+
+	for _, args := range helpArguments {
+		buf := new(bytes.Buffer)
+
+		t.Logf("==> checking with arguments %v", args)
+
+		app := NewApp()
+		app.Name = "boom"
+		app.Usage = "make an explosive entrance"
+		app.Writer = buf
+		app.Action = func(c *Context) {
+			buf.WriteString("boom I say!")
+		}
+
+		err := app.Run(args)
+		if err != nil {
+			t.Error(err)
+		}
+
+		output := buf.String()
+		t.Logf("output: %q\n", buf.Bytes())
+
+		if !strings.Contains(output, "boom - make an explosive entrance") {
+			t.Errorf("want help to contain %q, did not: \n%q", "boom - make an explosive entrance", output)
+		}
+	}
+}
+
+func TestApp_Run_Version(t *testing.T) {
+	var versionArguments = [][]string{{"boom", "--version"}, {"boom", "-v"}}
+
+	for _, args := range versionArguments {
+		buf := new(bytes.Buffer)
+
+		t.Logf("==> checking with arguments %v", args)
+
+		app := NewApp()
+		app.Name = "boom"
+		app.Usage = "make an explosive entrance"
+		app.Version = "0.1.0"
+		app.Writer = buf
+		app.Action = func(c *Context) {
+			buf.WriteString("boom I say!")
+		}
+
+		err := app.Run(args)
+		if err != nil {
+			t.Error(err)
+		}
+
+		output := buf.String()
+		t.Logf("output: %q\n", buf.Bytes())
+
+		if !strings.Contains(output, "0.1.0") {
+			t.Errorf("want version to contain %q, did not: \n%q", "0.1.0", output)
+		}
+	}
+}
+
+func TestApp_Run_DoesNotOverwriteErrorFromBefore(t *testing.T) {
+	app := NewApp()
+	app.Action = func(c *Context) {}
+	app.Before = func(c *Context) error { return fmt.Errorf("before error") }
+	app.After = func(c *Context) error { return fmt.Errorf("after error") }
+
+	err := app.Run([]string{"foo"})
+	if err == nil {
+		t.Fatalf("expected to receive error from Run, got none")
+	}
+
+	if !strings.Contains(err.Error(), "before error") {
+		t.Errorf("expected text of error from Before method, but got none in \"%v\"", err)
+	}
+	if !strings.Contains(err.Error(), "after error") {
+		t.Errorf("expected text of error from After method, but got none in \"%v\"", err)
+	}
+}
+
+func TestApp_Run_SubcommandDoesNotOverwriteErrorFromBefore(t *testing.T) {
+	app := NewApp()
+	app.Commands = []Command{
+		Command{
+			Subcommands: []Command{
+				Command{
+					Name: "sub",
+				},
+			},
+			Name:   "bar",
+			Before: func(c *Context) error { return fmt.Errorf("before error") },
+			After:  func(c *Context) error { return fmt.Errorf("after error") },
+		},
+	}
+
+	err := app.Run([]string{"foo", "bar"})
+	if err == nil {
+		t.Fatalf("expected to receive error from Run, got none")
+	}
+
+	if !strings.Contains(err.Error(), "before error") {
+		t.Errorf("expected text of error from Before method, but got none in \"%v\"", err)
+	}
+	if !strings.Contains(err.Error(), "after error") {
+		t.Errorf("expected text of error from After method, but got none in \"%v\"", err)
+	}
+}
+
+func TestApp_OnUsageError_WithWrongFlagValue(t *testing.T) {
+	app := NewApp()
+	app.Flags = []Flag{
+		IntFlag{Name: "flag"},
+	}
+	app.OnUsageError = func(c *Context, err error, isSubcommand bool) error {
+		if isSubcommand {
+			t.Errorf("Expect no subcommand")
+		}
+		if !strings.HasPrefix(err.Error(), "invalid value \"wrong\"") {
+			t.Errorf("Expect an invalid value error, but got \"%v\"", err)
+		}
+		return errors.New("intercepted: " + err.Error())
+	}
+	app.Commands = []Command{
+		Command{
+			Name: "bar",
+		},
+	}
+
+	err := app.Run([]string{"foo", "--flag=wrong"})
+	if err == nil {
+		t.Fatalf("expected to receive error from Run, got none")
+	}
+
+	if !strings.HasPrefix(err.Error(), "intercepted: invalid value") {
+		t.Errorf("Expect an intercepted error, but got \"%v\"", err)
+	}
+}
+
+func TestApp_OnUsageError_WithWrongFlagValue_ForSubcommand(t *testing.T) {
+	app := NewApp()
+	app.Flags = []Flag{
+		IntFlag{Name: "flag"},
+	}
+	app.OnUsageError = func(c *Context, err error, isSubcommand bool) error {
+		if isSubcommand {
+			t.Errorf("Expect subcommand")
+		}
+		if !strings.HasPrefix(err.Error(), "invalid value \"wrong\"") {
+			t.Errorf("Expect an invalid value error, but got \"%v\"", err)
+		}
+		return errors.New("intercepted: " + err.Error())
+	}
+	app.Commands = []Command{
+		Command{
+			Name: "bar",
+		},
+	}
+
+	err := app.Run([]string{"foo", "--flag=wrong", "bar"})
+	if err == nil {
+		t.Fatalf("expected to receive error from Run, got none")
+	}
+
+	if !strings.HasPrefix(err.Error(), "intercepted: invalid value") {
+		t.Errorf("Expect an intercepted error, but got \"%v\"", err)
+	}
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/799e9ccb/cli/vendor/github.com/urfave/cli/appveyor.yml
----------------------------------------------------------------------
diff --git a/cli/vendor/github.com/urfave/cli/appveyor.yml b/cli/vendor/github.com/urfave/cli/appveyor.yml
new file mode 100644
index 0000000..3ca7afa
--- /dev/null
+++ b/cli/vendor/github.com/urfave/cli/appveyor.yml
@@ -0,0 +1,16 @@
+version: "{build}"
+
+os: Windows Server 2012 R2
+
+install:
+  - go version
+  - go env
+
+build_script:
+  - cd %APPVEYOR_BUILD_FOLDER%
+  - go vet ./...
+  - go test -v ./...
+
+test: off
+
+deploy: off

http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/799e9ccb/cli/vendor/github.com/urfave/cli/autocomplete/bash_autocomplete
----------------------------------------------------------------------
diff --git a/cli/vendor/github.com/urfave/cli/autocomplete/bash_autocomplete b/cli/vendor/github.com/urfave/cli/autocomplete/bash_autocomplete
new file mode 100644
index 0000000..21a232f
--- /dev/null
+++ b/cli/vendor/github.com/urfave/cli/autocomplete/bash_autocomplete
@@ -0,0 +1,14 @@
+#! /bin/bash
+
+: ${PROG:=$(basename ${BASH_SOURCE})}
+
+_cli_bash_autocomplete() {
+     local cur opts base
+     COMPREPLY=()
+     cur="${COMP_WORDS[COMP_CWORD]}"
+     opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion )
+     COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+     return 0
+ }
+  
+ complete -F _cli_bash_autocomplete $PROG

http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/799e9ccb/cli/vendor/github.com/urfave/cli/autocomplete/zsh_autocomplete
----------------------------------------------------------------------
diff --git a/cli/vendor/github.com/urfave/cli/autocomplete/zsh_autocomplete b/cli/vendor/github.com/urfave/cli/autocomplete/zsh_autocomplete
new file mode 100644
index 0000000..5430a18
--- /dev/null
+++ b/cli/vendor/github.com/urfave/cli/autocomplete/zsh_autocomplete
@@ -0,0 +1,5 @@
+autoload -U compinit && compinit
+autoload -U bashcompinit && bashcompinit
+
+script_dir=$(dirname $0)
+source ${script_dir}/bash_autocomplete

http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/799e9ccb/cli/vendor/github.com/urfave/cli/cli.go
----------------------------------------------------------------------
diff --git a/cli/vendor/github.com/urfave/cli/cli.go b/cli/vendor/github.com/urfave/cli/cli.go
new file mode 100644
index 0000000..31dc912
--- /dev/null
+++ b/cli/vendor/github.com/urfave/cli/cli.go
@@ -0,0 +1,40 @@
+// Package cli provides a minimal framework for creating and organizing command line
+// Go applications. cli is designed to be easy to understand and write, the most simple
+// cli application can be written as follows:
+//   func main() {
+//     cli.NewApp().Run(os.Args)
+//   }
+//
+// Of course this application does not do much, so let's make this an actual application:
+//   func main() {
+//     app := cli.NewApp()
+//     app.Name = "greet"
+//     app.Usage = "say a greeting"
+//     app.Action = func(c *cli.Context) {
+//       println("Greetings")
+//     }
+//
+//     app.Run(os.Args)
+//   }
+package cli
+
+import (
+	"strings"
+)
+
+type MultiError struct {
+	Errors []error
+}
+
+func NewMultiError(err ...error) MultiError {
+	return MultiError{Errors: err}
+}
+
+func (m MultiError) Error() string {
+	errs := make([]string, len(m.Errors))
+	for i, err := range m.Errors {
+		errs[i] = err.Error()
+	}
+
+	return strings.Join(errs, "\n")
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/799e9ccb/cli/vendor/github.com/urfave/cli/command.go
----------------------------------------------------------------------
diff --git a/cli/vendor/github.com/urfave/cli/command.go b/cli/vendor/github.com/urfave/cli/command.go
new file mode 100644
index 0000000..0153713
--- /dev/null
+++ b/cli/vendor/github.com/urfave/cli/command.go
@@ -0,0 +1,250 @@
+package cli
+
+import (
+	"fmt"
+	"io/ioutil"
+	"strings"
+)
+
+// Command is a subcommand for a cli.App.
+type Command struct {
+	// The name of the command
+	Name string
+	// short name of the command. Typically one character (deprecated, use `Aliases`)
+	ShortName string
+	// A list of aliases for the command
+	Aliases []string
+	// A short description of the usage of this command
+	Usage string
+	// Custom text to show on USAGE section of help
+	UsageText string
+	// A longer explanation of how the command works
+	Description string
+	// A short description of the arguments of this command
+	ArgsUsage string
+	// The function to call when checking for bash command completions
+	BashComplete func(context *Context)
+	// An action to execute before any sub-subcommands are run, but after the context is ready
+	// If a non-nil error is returned, no sub-subcommands are run
+	Before func(context *Context) error
+	// An action to execute after any subcommands are run, but before the subcommand has finished
+	// It is run even if Action() panics
+	After func(context *Context) error
+	// The function to call when this command is invoked
+	Action func(context *Context)
+	// Execute this function, if an usage error occurs. This is useful for displaying customized usage error messages.
+	// This function is able to replace the original error messages.
+	// If this function is not set, the "Incorrect usage" is displayed and the execution is interrupted.
+	OnUsageError func(context *Context, err error) error
+	// List of child commands
+	Subcommands []Command
+	// List of flags to parse
+	Flags []Flag
+	// Treat all flags as normal arguments if true
+	SkipFlagParsing bool
+	// Boolean to hide built-in help command
+	HideHelp bool
+
+	// Full name of command for help, defaults to full command name, including parent commands.
+	HelpName        string
+	commandNamePath []string
+}
+
+// Returns the full name of the command.
+// For subcommands this ensures that parent commands are part of the command path
+func (c Command) FullName() string {
+	if c.commandNamePath == nil {
+		return c.Name
+	}
+	return strings.Join(c.commandNamePath, " ")
+}
+
+// Invokes the command given the context, parses ctx.Args() to generate command-specific flags
+func (c Command) Run(ctx *Context) (err error) {
+	if len(c.Subcommands) > 0 {
+		return c.startApp(ctx)
+	}
+
+	if !c.HideHelp && (HelpFlag != BoolFlag{}) {
+		// append help to flags
+		c.Flags = append(
+			c.Flags,
+			HelpFlag,
+		)
+	}
+
+	if ctx.App.EnableBashCompletion {
+		c.Flags = append(c.Flags, BashCompletionFlag)
+	}
+
+	set := flagSet(c.Name, c.Flags)
+	set.SetOutput(ioutil.Discard)
+
+	if !c.SkipFlagParsing {
+		firstFlagIndex := -1
+		terminatorIndex := -1
+		for index, arg := range ctx.Args() {
+			if arg == "--" {
+				terminatorIndex = index
+				break
+			} else if arg == "-" {
+				// Do nothing. A dash alone is not really a flag.
+				continue
+			} else if strings.HasPrefix(arg, "-") && firstFlagIndex == -1 {
+				firstFlagIndex = index
+			}
+		}
+
+		if firstFlagIndex > -1 {
+			args := ctx.Args()
+			regularArgs := make([]string, len(args[1:firstFlagIndex]))
+			copy(regularArgs, args[1:firstFlagIndex])
+
+			var flagArgs []string
+			if terminatorIndex > -1 {
+				flagArgs = args[firstFlagIndex:terminatorIndex]
+				regularArgs = append(regularArgs, args[terminatorIndex:]...)
+			} else {
+				flagArgs = args[firstFlagIndex:]
+			}
+
+			err = set.Parse(append(flagArgs, regularArgs...))
+		} else {
+			err = set.Parse(ctx.Args().Tail())
+		}
+	} else {
+		if c.SkipFlagParsing {
+			err = set.Parse(append([]string{"--"}, ctx.Args().Tail()...))
+		}
+	}
+
+	if err != nil {
+		if c.OnUsageError != nil {
+			err := c.OnUsageError(ctx, err)
+			return err
+		} else {
+			fmt.Fprintln(ctx.App.Writer, "Incorrect Usage.")
+			fmt.Fprintln(ctx.App.Writer)
+			ShowCommandHelp(ctx, c.Name)
+			return err
+		}
+	}
+
+	nerr := normalizeFlags(c.Flags, set)
+	if nerr != nil {
+		fmt.Fprintln(ctx.App.Writer, nerr)
+		fmt.Fprintln(ctx.App.Writer)
+		ShowCommandHelp(ctx, c.Name)
+		return nerr
+	}
+	context := NewContext(ctx.App, set, ctx)
+
+	if checkCommandCompletions(context, c.Name) {
+		return nil
+	}
+
+	if checkCommandHelp(context, c.Name) {
+		return nil
+	}
+
+	if c.After != nil {
+		defer func() {
+			afterErr := c.After(context)
+			if afterErr != nil {
+				if err != nil {
+					err = NewMultiError(err, afterErr)
+				} else {
+					err = afterErr
+				}
+			}
+		}()
+	}
+
+	if c.Before != nil {
+		err := c.Before(context)
+		if err != nil {
+			fmt.Fprintln(ctx.App.Writer, err)
+			fmt.Fprintln(ctx.App.Writer)
+			ShowCommandHelp(ctx, c.Name)
+			return err
+		}
+	}
+
+	context.Command = c
+	c.Action(context)
+	return nil
+}
+
+func (c Command) Names() []string {
+	names := []string{c.Name}
+
+	if c.ShortName != "" {
+		names = append(names, c.ShortName)
+	}
+
+	return append(names, c.Aliases...)
+}
+
+// Returns true if Command.Name or Command.ShortName matches given name
+func (c Command) HasName(name string) bool {
+	for _, n := range c.Names() {
+		if n == name {
+			return true
+		}
+	}
+	return false
+}
+
+func (c Command) startApp(ctx *Context) error {
+	app := NewApp()
+
+	// set the name and usage
+	app.Name = fmt.Sprintf("%s %s", ctx.App.Name, c.Name)
+	if c.HelpName == "" {
+		app.HelpName = c.HelpName
+	} else {
+		app.HelpName = app.Name
+	}
+
+	if c.Description != "" {
+		app.Usage = c.Description
+	} else {
+		app.Usage = c.Usage
+	}
+
+	// set CommandNotFound
+	app.CommandNotFound = ctx.App.CommandNotFound
+
+	// set the flags and commands
+	app.Commands = c.Subcommands
+	app.Flags = c.Flags
+	app.HideHelp = c.HideHelp
+
+	app.Version = ctx.App.Version
+	app.HideVersion = ctx.App.HideVersion
+	app.Compiled = ctx.App.Compiled
+	app.Author = ctx.App.Author
+	app.Email = ctx.App.Email
+	app.Writer = ctx.App.Writer
+
+	// bash completion
+	app.EnableBashCompletion = ctx.App.EnableBashCompletion
+	if c.BashComplete != nil {
+		app.BashComplete = c.BashComplete
+	}
+
+	// set the actions
+	app.Before = c.Before
+	app.After = c.After
+	if c.Action != nil {
+		app.Action = c.Action
+	} else {
+		app.Action = helpSubcommand.Action
+	}
+
+	for index, cc := range app.Commands {
+		app.Commands[index].commandNamePath = []string{c.Name, cc.Name}
+	}
+
+	return app.RunAsSubcommand(ctx)
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/799e9ccb/cli/vendor/github.com/urfave/cli/command_test.go
----------------------------------------------------------------------
diff --git a/cli/vendor/github.com/urfave/cli/command_test.go b/cli/vendor/github.com/urfave/cli/command_test.go
new file mode 100644
index 0000000..827da1d
--- /dev/null
+++ b/cli/vendor/github.com/urfave/cli/command_test.go
@@ -0,0 +1,97 @@
+package cli
+
+import (
+	"errors"
+	"flag"
+	"fmt"
+	"io/ioutil"
+	"strings"
+	"testing"
+)
+
+func TestCommandFlagParsing(t *testing.T) {
+	cases := []struct {
+		testArgs        []string
+		skipFlagParsing bool
+		expectedErr     error
+	}{
+		{[]string{"blah", "blah", "-break"}, false, errors.New("flag provided but not defined: -break")}, // Test normal "not ignoring flags" flow
+		{[]string{"blah", "blah"}, true, nil},                                                            // Test SkipFlagParsing without any args that look like flags
+		{[]string{"blah", "-break"}, true, nil},                                                          // Test SkipFlagParsing with random flag arg
+		{[]string{"blah", "-help"}, true, nil},                                                           // Test SkipFlagParsing with "special" help flag arg
+	}
+
+	for _, c := range cases {
+		app := NewApp()
+		app.Writer = ioutil.Discard
+		set := flag.NewFlagSet("test", 0)
+		set.Parse(c.testArgs)
+
+		context := NewContext(app, set, nil)
+
+		command := Command{
+			Name:        "test-cmd",
+			Aliases:     []string{"tc"},
+			Usage:       "this is for testing",
+			Description: "testing",
+			Action:      func(_ *Context) {},
+		}
+
+		command.SkipFlagParsing = c.skipFlagParsing
+
+		err := command.Run(context)
+
+		expect(t, err, c.expectedErr)
+		expect(t, []string(context.Args()), c.testArgs)
+	}
+}
+
+func TestCommand_Run_DoesNotOverwriteErrorFromBefore(t *testing.T) {
+	app := NewApp()
+	app.Commands = []Command{
+		Command{
+			Name:   "bar",
+			Before: func(c *Context) error { return fmt.Errorf("before error") },
+			After:  func(c *Context) error { return fmt.Errorf("after error") },
+		},
+	}
+
+	err := app.Run([]string{"foo", "bar"})
+	if err == nil {
+		t.Fatalf("expected to receive error from Run, got none")
+	}
+
+	if !strings.Contains(err.Error(), "before error") {
+		t.Errorf("expected text of error from Before method, but got none in \"%v\"", err)
+	}
+	if !strings.Contains(err.Error(), "after error") {
+		t.Errorf("expected text of error from After method, but got none in \"%v\"", err)
+	}
+}
+
+func TestCommand_OnUsageError_WithWrongFlagValue(t *testing.T) {
+	app := NewApp()
+	app.Commands = []Command{
+		Command{
+			Name:   "bar",
+			Flags: []Flag{
+				IntFlag{Name: "flag"},
+			},
+			OnUsageError: func(c *Context, err error) error {
+				if !strings.HasPrefix(err.Error(), "invalid value \"wrong\"") {
+					t.Errorf("Expect an invalid value error, but got \"%v\"", err)
+				}
+				return errors.New("intercepted: " + err.Error())
+			},
+		},
+	}
+
+	err := app.Run([]string{"foo", "bar", "--flag=wrong"})
+	if err == nil {
+		t.Fatalf("expected to receive error from Run, got none")
+	}
+
+	if !strings.HasPrefix(err.Error(), "intercepted: invalid value") {
+		t.Errorf("Expect an intercepted error, but got \"%v\"", err)
+	}
+}