Exemplo n.º 1
0
func main() {
	app := cli.NewApp()
	app.Name = "gumshoe"
	app.Usage = "talks to tracker"

	config := trackerapi.NewConfiguration()
	client, err := trackerapi.NewClient(config)
	if err != nil {
		panic(err)
	}
	terminal := term.New()
	app.Commands = []cli.Command{
		{
			Name:  "me",
			Usage: "prints out Tracker's representation of your account",
			Action: func(c *cli.Context) {
				handleAuthentication(client, terminal)
				output := client.Me()
				fmt.Println(output)
			},
		},
		{
			Name:  "projects",
			Usage: "prints out a list of Tracker projects for your account",
			Action: func(c *cli.Context) {
				handleAuthentication(client, terminal)
				output := client.Projects()
				fmt.Println(output)
			},
		},
		{
			Name:  "activity",
			Usage: "lists last 5 activities for a given project",
			Action: func(c *cli.Context) {
				if len(c.Args()) == 0 {
					fmt.Println("Please supply a project ID")
					os.Exit(1)
				}
				projectID, err := strconv.Atoi(c.Args()[0])
				if err != nil {
					fmt.Println("Something went wrong parsing the Project ID.", err)
					os.Exit(1)
				}
				handleAuthentication(client, terminal)
				output := client.Activity(projectID)
				fmt.Println(output)
			},
		},
	}

	app.Run(os.Args)
}
Exemplo n.º 2
0
package term_test

import (
	. "github.com/pivotal/gumshoe/repos/ginkgo"
	. "github.com/pivotal/gumshoe/repos/gomega"
	"github.com/pivotal/gumshoe/term"

	"io/ioutil"
	"os"
)

var _ = Describe("term", func() {
	Describe("New", func() {
		var terminal *term.Terminal
		BeforeEach(func() {
			terminal = term.New()
		})

		It("returns an instance of Terminal", func() {
			Expect(terminal).To(BeAssignableToTypeOf(&term.Terminal{}))
		})

		It("defaults the InputFile to os.Stdin", func() {
			Expect(terminal.InputFile).To(Equal(os.Stdin))
		})

		It("defaults the OutputFile to os.Stdout", func() {
			Expect(terminal.OutputFile).To(Equal(os.Stdout))
		})
	})