예제 #1
0
func Slurp(b *slurp.Build) {
	b.Task(slurp.Task{
		Name: "default",
		Action: func(c *slurp.C) error {
			return nil
		}})
}
예제 #2
0
func Slurp(b *slurp.Build) {

	b.Task(
		slurp.Task{
			Name: "turtle",
			Action: func(c *slurp.C) error {
				c.Info("Hello!")
				c.Warn("I will take at least 3 seconds.")
				time.Sleep(3 * time.Second)
				c.Info("Well, here is a line.")
				return errors.New("I died.")
			},
		},

		slurp.Task{
			Name: "medic",
			Action: func(c *slurp.C) error {
				c.Info("I might be able to help, Go ahead.")
				return nil
			},
		},

		slurp.Task{
			Name: "rabbit",
			Deps: []string{"medic"},
			Action: func(c *slurp.C) error {
				c.Info("Hello, I am the the fast one.")
				for i := 0; i < 4; i++ {
					c.Infof("This is the %d line of my work.", i)
					time.Sleep(500 * time.Millisecond)
				}
				return nil
			},
		},

		slurp.Task{
			Name: "default",
			Deps: []string{"turtle", "rabbit"},
			Action: func(c *slurp.C) error {
				//This task is run when slurp is called with any task parameter.
				c.Info("Default task is running.")
				return nil
			},
		},
	)
}
예제 #3
0
파일: cancel.go 프로젝트: nelsonomuto/slurp
func Slurp(b *slurp.Build) {
	b.Task(
		slurp.Task{
			Name: "turtle",
			Action: func(c *slurp.C) error {

				c.Info("Hello!")
				c.Warn("I will take at least 4 second unless cancled.")
				select {
				case <-c.Done():
					c.Warn("Got cancel, leaving.")
					return nil
				case <-time.Tick(4 * time.Second):
					c.Info("I am done!")
					return nil
				}
				c.Info("You shouldn't see this!")
				return nil
			},
		},

		slurp.Task{
			Name: "medic",
			Action: func(c *slurp.C) error {
				c.Info("I might be able to help, Go ahead.")
				return nil
			},
		},

		slurp.Task{
			Name: "rabbit",
			Deps: []string{"medic"},
			Action: func(c *slurp.C) error {

				c.Info("Hello, I am the the fast one.")
				for i := 0; i < 4; i++ {
					c.Infof("This is the %d line of my work.", i)
					time.Sleep(500 * time.Millisecond)
				}
				c.Notice("I take at least 4 seconds after cancel. Try me!")
				<-c.Done()
				c.Info("Got cancel but nope. I am not leaving.")
				time.Sleep(4 * time.Second)
				return nil

			},
		},

		slurp.Task{
			Name: "default",
			Deps: []string{"turtle", "rabbit"},
			Action: func(c *slurp.C) error {

				//This task is run when slurp is called with any task parameter.
				c.Info("Default task is running.")
				return nil

			},
		},
	)
}
예제 #4
0
파일: run.go 프로젝트: nelsonomuto/slurp
func Slurp(b *slurp.Build) {

	b.Task(
		slurp.Task{
			Name: "a",
			Action: func(c *slurp.C) error {
				return nil
			},
		},

		slurp.Task{
			Name: "b",
			Action: func(c *slurp.C) error {
				return nil
			},
		},

		slurp.Task{
			Name: "c",
			Action: func(c *slurp.C) error {
				return nil
			},
		},

		slurp.Task{
			Name: "default",
			Deps: []string{"a", "b", "c"},
			Action: func(c *slurp.C) error {

				b.Warn("Calling locally.")
				b.Run(c, "a", "b", "c")
				b.Warn("Calling One by one.")
				b.Run(c, "a")
				b.Run(c, "b")
				b.Run(c, "c")
				return nil
			},
		},
	)

}
예제 #5
0
func Slurp(b *slurp.Build) {
	b.Task("default", nil, func(c *slurp.C) error {
		return nil
	})
}