1
0
Fork 0

Input outside of a unit

This commit is contained in:
Gregory Eremin 2014-08-30 20:53:41 +07:00
parent 509f281f72
commit 6c8fd03a69
No known key found for this signature in database
GPG Key ID: 5EFA427EEC26E86C
4 changed files with 14 additions and 28 deletions

View File

@ -1,17 +1,23 @@
package main
import (
"flag"
"code.google.com/p/go.net/context"
"github.com/localhots/yeast/core"
)
func main() {
var num int
flag.IntVar(&num, "num", 0, "Pass this number")
flag.Parse()
chain, ok := core.NewChain("calculate")
if !ok {
println("Bad chain: calculate")
return
}
ctx := context.Background()
ctx := context.WithValue(context.Background(), "num", num)
core.ProcessChain(ctx, chain)
}

View File

@ -2,7 +2,6 @@
"calculate": {
"s": [
"uuid",
"input_from_flag",
{
"p": [
"power2",

View File

@ -3,7 +3,6 @@ package core
import (
"code.google.com/p/go.net/context"
"github.com/localhots/yeast/units/aggregator"
"github.com/localhots/yeast/units/input"
"github.com/localhots/yeast/units/logger"
"github.com/localhots/yeast/units/power"
"github.com/localhots/yeast/units/sleep"
@ -16,13 +15,12 @@ type (
var (
Units = UnitsDict{
"aggregator": aggregator.Call,
"logger": logger.Call,
"power2": power.Power2,
"power3": power.Power3,
"power5": power.Power5,
"input_from_flag": input.FromFlag,
"sleep": sleep.Call,
"uuid": uuid.Call,
"aggregator": aggregator.Call,
"logger": logger.Call,
"power2": power.Power2,
"power3": power.Power3,
"power5": power.Power5,
"sleep": sleep.Call,
"uuid": uuid.Call,
}
)

View File

@ -1,17 +0,0 @@
package input
import (
"flag"
"code.google.com/p/go.net/context"
)
func FromFlag(ctx context.Context) context.Context {
var num int
flag.IntVar(&num, "num", 0, "Pass this number")
flag.Parse()
ctx = context.WithValue(ctx, "num", num)
return ctx
}