Skip to content

Commit

Permalink
Merge pull request #39 from convox/cmd-service
Browse files Browse the repository at this point in the history
add service cmd
  • Loading branch information
csquared committed Sep 22, 2015
2 parents 720fc8e + dd398de commit 6f69839
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/service/Makefile
@@ -0,0 +1,7 @@
.PHONY: all test

all: test

test:
go get -t ./...
go test -v -cover ./...
35 changes: 35 additions & 0 deletions cmd/service/main.go
@@ -0,0 +1,35 @@
package main

import (
"fmt"
"os"
"strings"

"github.com/convox/rack/api/models"
)

func die(err error) {
fmt.Fprintf(os.Stderr, "ERROR: %s\n", err.Error())
os.Exit(1)
}

func main() {
if len(os.Args) < 2 {
fmt.Fprintf(os.Stderr, "usage: service <type>\n")
os.Exit(1)
}

service := models.Service{Type: os.Args[1]}

out, err := service.Formation()

if err != nil && strings.HasSuffix(err.Error(), "not found") {
die(fmt.Errorf("no such service type: %s", service.Type))
}

if err != nil {
die(err)
}

fmt.Println(out)
}

0 comments on commit 6f69839

Please sign in to comment.