Rename the coco nut
command to coco pack
This commit is contained in:
parent
9f524e4c8c
commit
bfee271087
|
@ -42,7 +42,7 @@ func NewCoconutCmd() *cobra.Command {
|
|||
&verbose, "verbose", "v", 0, "Enable verbose logging (e.g., v=3); anything >3 is very verbose")
|
||||
|
||||
cmd.AddCommand(newEnvCmd())
|
||||
cmd.AddCommand(newNutCmd())
|
||||
cmd.AddCommand(newPackCmd())
|
||||
cmd.AddCommand(newVersionCmd())
|
||||
|
||||
return cmd
|
||||
|
|
|
@ -14,20 +14,20 @@ func newEnvDeployCmd() *cobra.Command {
|
|||
var summary bool
|
||||
var output string
|
||||
var cmd = &cobra.Command{
|
||||
Use: "deploy <env> [<nut>] [-- [<args>]]",
|
||||
Use: "deploy <env> [<package>] [-- [<args>]]",
|
||||
Aliases: []string{"up", "update"},
|
||||
Short: "Deploy resource updates, creations, and deletions to an environment",
|
||||
Long: "Deploy resource updates, creations, and deletions to an environment\n" +
|
||||
"\n" +
|
||||
"This command updates an existing environment whose state is represented by the\n" +
|
||||
"existing snapshot file. The new desired state is computed by compiling and evaluating\n" +
|
||||
"an executable Nut, and extracting all resource allocations from its resulting object graph.\n" +
|
||||
"existing snapshot file. The new desired state is computed by compiling and evaluating an\n" +
|
||||
"executable package, and extracting all resource allocations from its resulting object graph.\n" +
|
||||
"This graph is compared against the existing state to determine what operations must take\n" +
|
||||
"place to achieve the desired state. This command results in a full snapshot of the\n" +
|
||||
"environment's new resource state, so that it may be updated incrementally again later.\n" +
|
||||
"\n" +
|
||||
"By default, the Nut to execute is loaded from the current directory. Optionally, an\n" +
|
||||
"explicit path can be provided using the [nut] argument.",
|
||||
"By default, the package to execute is loaded from the current directory. Optionally, an\n" +
|
||||
"explicit path can be provided using the [package] argument.",
|
||||
Run: runFunc(func(cmd *cobra.Command, args []string) error {
|
||||
info, err := initEnvCmd(cmd, args)
|
||||
if err != nil {
|
||||
|
|
21
cmd/nut.go
21
cmd/nut.go
|
@ -1,21 +0,0 @@
|
|||
// Copyright 2016 Pulumi, Inc. All rights reserved.
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func newNutCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "nut",
|
||||
Short: "Manage Nuts (packages)",
|
||||
}
|
||||
|
||||
cmd.AddCommand(newNutEvalCmd())
|
||||
cmd.AddCommand(newNutInfoCmd())
|
||||
cmd.AddCommand(newNutGetCmd())
|
||||
cmd.AddCommand(newNutVerifyCmd())
|
||||
|
||||
return cmd
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
// Copyright 2016 Pulumi, Inc. All rights reserved.
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func newNutVerifyCmd() *cobra.Command {
|
||||
var cmd = &cobra.Command{
|
||||
Use: "verify [package]",
|
||||
Short: "Check that a Nut and its NutIL are correct",
|
||||
Long: "Check that a Nut and its NutIL are correct\n" +
|
||||
"\n" +
|
||||
"A Nut contains intermediate language (NutIL) that encodes symbols,\n" +
|
||||
"definitions, and executable code. This NutIL must obey a set of specific rules\n" +
|
||||
"for it to be valid. Otherwise, evaluating it will fail.\n" +
|
||||
"\n" +
|
||||
"The verify command thoroughly checks the NutIL against these rules, and issues\n" +
|
||||
"errors anywhere it doesn't obey them. This is generally useful for tools developers\n" +
|
||||
"and can ensure that Nuts do not fail at runtime, when such invariants are checked.",
|
||||
Run: runFunc(func(cmd *cobra.Command, args []string) error {
|
||||
// Create a compiler object and perform the verification.
|
||||
if !verify(cmd, args) {
|
||||
return errors.New("verification failed")
|
||||
}
|
||||
return nil
|
||||
}),
|
||||
}
|
||||
|
||||
return cmd
|
||||
}
|
21
cmd/pack.go
Normal file
21
cmd/pack.go
Normal file
|
@ -0,0 +1,21 @@
|
|||
// Copyright 2016 Pulumi, Inc. All rights reserved.
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func newPackCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "pack",
|
||||
Short: "Manage packages",
|
||||
}
|
||||
|
||||
cmd.AddCommand(newPackEvalCmd())
|
||||
cmd.AddCommand(newPackInfoCmd())
|
||||
cmd.AddCommand(newPackGetCmd())
|
||||
cmd.AddCommand(newPackVerifyCmd())
|
||||
|
||||
return cmd
|
||||
}
|
|
@ -16,20 +16,20 @@ import (
|
|||
"github.com/pulumi/coconut/pkg/tokens"
|
||||
)
|
||||
|
||||
func newNutEvalCmd() *cobra.Command {
|
||||
func newPackEvalCmd() *cobra.Command {
|
||||
var dotOutput bool
|
||||
var cmd = &cobra.Command{
|
||||
Use: "eval [nut] [-- [args]]",
|
||||
Short: "Evaluate a Nut and print the resulting objects",
|
||||
Long: "Evaluate a Nut and print the resulting objects\n" +
|
||||
Use: "eval [package] [-- [args]]",
|
||||
Short: "Evaluate a package and print the resulting objects",
|
||||
Long: "Evaluate a package and print the resulting objects\n" +
|
||||
"\n" +
|
||||
"A graph is a topologically sorted directed-acyclic-graph (DAG), representing a\n" +
|
||||
"collection of resources that may be used in a deployment operation like plan or apply.\n" +
|
||||
"This graph is produced by evaluating the contents of a Nut blueprint, and does not\n" +
|
||||
"This graph is produced by evaluating the contents of a blueprint package, and does not\n" +
|
||||
"actually perform any updates to the target environment.\n" +
|
||||
"\n" +
|
||||
"By default, a blueprint package is loaded from the current directory. Optionally,\n" +
|
||||
"a path to a blueprint elsewhere can be provided as the [blueprint] argument.",
|
||||
"a path to a package elsewhere can be provided as the [package] argument.",
|
||||
Run: runFunc(func(cmd *cobra.Command, args []string) error {
|
||||
// Perform the compilation and, if non-nil is returned, output the graph.
|
||||
if result := compile(cmd, args, nil); result != nil {
|
||||
|
@ -76,7 +76,7 @@ func printVertex(v *heapstate.ObjectVertex, shown map[graph.Vertex]bool, indent
|
|||
}
|
||||
|
||||
// dashdashArgsToMap is a simple args parser that places incoming key/value pairs into a map. These are then used
|
||||
// during Nut compilation as inputs to the main entrypoint function.
|
||||
// during package compilation as inputs to the main entrypoint function.
|
||||
// TODO: this is fairly rudimentary; we eventually want to support arrays, maps, and complex types.
|
||||
func dashdashArgsToMap(args []string) core.Args {
|
||||
mapped := make(core.Args)
|
|
@ -8,14 +8,14 @@ import (
|
|||
"github.com/pulumi/coconut/pkg/util/contract"
|
||||
)
|
||||
|
||||
func newNutGetCmd() *cobra.Command {
|
||||
func newPackGetCmd() *cobra.Command {
|
||||
var global bool
|
||||
var save bool
|
||||
var cmd = &cobra.Command{
|
||||
Use: "get [deps]",
|
||||
Short: "Download a Nut",
|
||||
Long: "Get downloads a Nut by name. If run without arguments, get will attempt\n" +
|
||||
"to download dependencies referenced by the current Nut. Otherwise, if one\n" +
|
||||
Short: "Download a package",
|
||||
Long: "Get downloads a package by name. If run without arguments, get will attempt\n" +
|
||||
"to download dependencies referenced by the current package. Otherwise, if one\n" +
|
||||
"or more specific dependencies are provided, only those will be downloaded.",
|
||||
Run: runFunc(func(cmd *cobra.Command, args []string) error {
|
||||
contract.Failf("Get command is not yet implemented")
|
||||
|
@ -28,7 +28,7 @@ func newNutGetCmd() *cobra.Command {
|
|||
"Install to a shared location on this machine")
|
||||
cmd.PersistentFlags().BoolVarP(
|
||||
&save, "save", "s", false,
|
||||
"Save new dependencies in the current Nut")
|
||||
"Save new dependencies in the current package")
|
||||
|
||||
return cmd
|
||||
}
|
|
@ -18,17 +18,17 @@ import (
|
|||
"github.com/pulumi/coconut/pkg/workspace"
|
||||
)
|
||||
|
||||
func newNutInfoCmd() *cobra.Command {
|
||||
func newPackInfoCmd() *cobra.Command {
|
||||
var printAll bool
|
||||
var printIL bool
|
||||
var printSymbols bool
|
||||
var printExportedSymbols bool
|
||||
var cmd = &cobra.Command{
|
||||
Use: "info [nuts...]",
|
||||
Short: "Print information about one or more Nuts",
|
||||
Long: "Print information about one or more Nuts\n" +
|
||||
Use: "info [packages...]",
|
||||
Short: "Print information about one or more packages",
|
||||
Long: "Print information about one or more packages\n" +
|
||||
"\n" +
|
||||
"This command prints package, symbol, and IL information from one or more nuts.",
|
||||
"This command prints metadata, symbol, and/or IL from one or more packages.",
|
||||
Run: runFunc(func(cmd *cobra.Command, args []string) error {
|
||||
// If printAll is true, flip all the flags.
|
||||
if printAll {
|
||||
|
@ -65,13 +65,13 @@ func newNutInfoCmd() *cobra.Command {
|
|||
|
||||
cmd.PersistentFlags().BoolVarP(
|
||||
&printSymbols, "all", "a", false,
|
||||
"Print everything: the package, symbols, and NutIL")
|
||||
"Print everything: the package, symbols, and IL")
|
||||
cmd.PersistentFlags().BoolVarP(
|
||||
&printExportedSymbols, "exports", "e", false,
|
||||
"Print just the exported symbols")
|
||||
cmd.PersistentFlags().BoolVarP(
|
||||
&printIL, "il", "i", false,
|
||||
"Pretty-print the NutIL")
|
||||
"Pretty-print the package's IL")
|
||||
cmd.PersistentFlags().BoolVarP(
|
||||
&printSymbols, "symbols", "s", false,
|
||||
"Print a complete listing of all symbols, exported or otherwise")
|
34
cmd/pack_verify.go
Normal file
34
cmd/pack_verify.go
Normal file
|
@ -0,0 +1,34 @@
|
|||
// Copyright 2016 Pulumi, Inc. All rights reserved.
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func newPackVerifyCmd() *cobra.Command {
|
||||
var cmd = &cobra.Command{
|
||||
Use: "verify [package]",
|
||||
Short: "Check that a package's metadata and IL are correct",
|
||||
Long: "Check that a package's metadata and IL are correct\n" +
|
||||
"\n" +
|
||||
"A package contains intermediate language (IL) that encodes symbols, definitions,\n" +
|
||||
"and executable code. This IL must obey a set of specific rules for it to be considered\n" +
|
||||
"legal and valid. Otherwise, evaluating it will fail.\n" +
|
||||
"\n" +
|
||||
"The verify command thoroughly checks the package's IL against these rules, and issues\n" +
|
||||
"errors anywhere it doesn't obey them. This is generally useful for tools developers\n" +
|
||||
"and can ensure that code does not fail at runtime, when such invariants are checked.",
|
||||
Run: runFunc(func(cmd *cobra.Command, args []string) error {
|
||||
// Create a compiler object and perform the verification.
|
||||
if !verify(cmd, args) {
|
||||
return errors.New("verification failed")
|
||||
}
|
||||
return nil
|
||||
}),
|
||||
}
|
||||
|
||||
return cmd
|
||||
}
|
Loading…
Reference in a new issue