-
Notifications
You must be signed in to change notification settings - Fork 151
/
repl.go
37 lines (33 loc) · 1011 Bytes
/
repl.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package cmd
import (
"context"
"github.com/influxdata/flux"
_ "github.com/influxdata/flux/builtin"
"github.com/influxdata/flux/dependencies/filesystem"
"github.com/influxdata/flux/plan"
"github.com/influxdata/flux/repl"
"github.com/influxdata/flux/stdlib/universe"
"github.com/spf13/cobra"
)
// replCmd represents the repl command
var replCmd = &cobra.Command{
Use: "repl",
Short: "Launch a Flux REPL",
Long: "Launch a Flux REPL (Read-Eval-Print-Loop)",
Run: func(cmd *cobra.Command, args []string) {
deps := flux.NewDefaultDependencies()
deps.Deps.FilesystemService = filesystem.SystemFS
// inject the dependencies to the context.
// one useful example is socket.from, kafka.to, and sql.from/sql.to where we need
// to access the url validator in deps to validate the user-specified url.
ctx := deps.Inject(context.Background())
r := repl.New(ctx, deps)
r.Run()
},
}
func init() {
rootCmd.AddCommand(replCmd)
plan.RegisterLogicalRules(
universe.MergeFiltersRule{},
)
}