Input outside of a unit
This commit is contained in:
parent
509f281f72
commit
6c8fd03a69
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
"calculate": {
|
||||
"s": [
|
||||
"uuid",
|
||||
"input_from_flag",
|
||||
{
|
||||
"p": [
|
||||
"power2",
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
)
|
||||
|
|
|
@ -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
|
||||
}
|
Loading…
Reference in New Issue