pulumi/cmd/mu.go
joeduffy 901c1cc6cf Add scaffolding for mu apply, compile, and plan
This adds scaffolding but no real functionality yet, as part of
marapongo/mu#41.  I am landing this now because I need to take a
not-so-brief detour to gut and overhaul the core of the existing
compiler (parsing, semantic analysis, binding, code-gen, etc),
including merging the new pkg/pack contents back into the primary
top-level namespaces (like pkg/ast and pkg/encoding).

After that, I can begin driving the compiler to achieve the
desired effects of mu compile, first and foremost, and then plan
and apply later on.
2017-01-17 14:40:55 -08:00

49 lines
1.3 KiB
Go

// Copyright 2016 Marapongo, Inc. All rights reserved.
package cmd
import (
"flag"
"strconv"
"github.com/golang/glog"
"github.com/spf13/cobra"
)
func NewMuCmd() *cobra.Command {
var logToStderr bool
var verbose int
cmd := &cobra.Command{
Use: "mu",
Short: "Mu is a framework and toolset for reusable stacks of services",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
// Ensure the glog library has been initialized, including calling flag.Parse beforehand. Unfortunately,
// this is the only way to control the way glog runs. That includes poking around at flags below.
flag.Parse()
if logToStderr {
flag.Lookup("logtostderr").Value.Set("true")
}
if verbose > 0 {
flag.Lookup("v").Value.Set(strconv.Itoa(verbose))
}
},
PersistentPostRun: func(cmd *cobra.Command, args []string) {
glog.Flush()
},
}
cmd.PersistentFlags().BoolVar(&logToStderr, "logtostderr", false, "Log to stderr instead of to files")
cmd.PersistentFlags().IntVarP(
&verbose, "verbose", "v", 0, "Enable verbose logging (e.g., v=3); anything >3 is very verbose")
cmd.AddCommand(newApplyCmd())
cmd.AddCommand(newBuildCmd())
cmd.AddCommand(newCompileCmd())
cmd.AddCommand(newDescribeCmd())
cmd.AddCommand(newGetCmd())
cmd.AddCommand(newPlanCmd())
cmd.AddCommand(newVersionCmd())
return cmd
}