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

View File

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

View File

@ -3,7 +3,6 @@ package core
import ( import (
"code.google.com/p/go.net/context" "code.google.com/p/go.net/context"
"github.com/localhots/yeast/units/aggregator" "github.com/localhots/yeast/units/aggregator"
"github.com/localhots/yeast/units/input"
"github.com/localhots/yeast/units/logger" "github.com/localhots/yeast/units/logger"
"github.com/localhots/yeast/units/power" "github.com/localhots/yeast/units/power"
"github.com/localhots/yeast/units/sleep" "github.com/localhots/yeast/units/sleep"
@ -21,7 +20,6 @@ var (
"power2": power.Power2, "power2": power.Power2,
"power3": power.Power3, "power3": power.Power3,
"power5": power.Power5, "power5": power.Power5,
"input_from_flag": input.FromFlag,
"sleep": sleep.Call, "sleep": sleep.Call,
"uuid": uuid.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
}