diff --git a/cmd/lumi/env.go b/cmd/lumi/env.go index 9a655e6bd..009083cc9 100644 --- a/cmd/lumi/env.go +++ b/cmd/lumi/env.go @@ -114,13 +114,20 @@ func initEnvCmdName(name tokens.QName, args []string) (*envCmdInfo, error) { if checkpoint == nil { return nil, goerr.Errorf("could not read environment information") } + + var pkgarg string + + if len(args) > 0 { + pkgarg = args[0] + } + contract.Assert(target != nil) contract.Assert(checkpoint != nil) return &envCmdInfo{ Target: target, Checkpoint: checkpoint, Snapshot: snapshot, - Args: args, + PackageArg: pkgarg, }, nil } @@ -128,7 +135,7 @@ type envCmdInfo struct { Target *deploy.Target // the target environment. Checkpoint *environment.Checkpoint // the full serialized checkpoint from which this came. Snapshot *deploy.Snapshot // the environment's latest deployment snapshot - Args []string // the args after extracting the environment name + PackageArg string // an optional path to a package to pass to the compiler } func confirmPrompt(msg string, name tokens.QName) bool { diff --git a/cmd/lumi/lumi.go b/cmd/lumi/lumi.go index b10257397..0cbd6cf45 100644 --- a/cmd/lumi/lumi.go +++ b/cmd/lumi/lumi.go @@ -48,14 +48,9 @@ func NewLumiCmd() *cobra.Command { return cmd } -func prepareCompiler(args []string) (compiler.Compiler, *pack.Package) { - // TODO[pulumi/pulumi-fabric#88]: enable arguments to flow to the package itself. In that case, we want to split the - // arguments at the --, if any, so we can still pass arguments to the compiler itself in these cases. - var pkgarg string - if len(args) > 0 { - pkgarg = args[0] - } - +// TODO[pulumi/pulumi-fabric#88]: enable arguments to flow to the package itself. In that case, we want to split the +// arguments at the --, if any, so we can still pass arguments to the compiler itself in these cases. +func prepareCompiler(pkgarg string) (compiler.Compiler, *pack.Package) { // Create a compiler options object and map any flags and arguments to settings on it. opts := core.DefaultOptions() @@ -83,9 +78,9 @@ func prepareCompiler(args []string) (compiler.Compiler, *pack.Package) { // compile just uses the standard logic to parse arguments, options, and to locate/compile a package. It returns the // compilation result, or nil if an error occurred (in which case, we would expect diagnostics to have been output). -func compile(args []string) *compileResult { +func compile(pkgarg string) *compileResult { // Prepare the compiler info and, provided it succeeds, perform the compilation. - if comp, pkg := prepareCompiler(args); comp != nil { + if comp, pkg := prepareCompiler(pkgarg); comp != nil { var b binder.Binder var pkgsym *symbols.Package if pkg == nil { diff --git a/cmd/lumi/pack_eval.go b/cmd/lumi/pack_eval.go index 91b309fe0..6e434c2a8 100644 --- a/cmd/lumi/pack_eval.go +++ b/cmd/lumi/pack_eval.go @@ -34,8 +34,14 @@ func newPackEvalCmd() *cobra.Command { Run: cmdutil.RunFunc(func(cmd *cobra.Command, args []string) error { contract.Assertf(!dotOutput, "TODO[pulumi/pulumi-fabric#235]: DOT files not yet supported") + var pkgarg string + + if len(args) > 0 { + pkgarg = args[0] + } + // First, load and compile the package. - result := compile(args) + result := compile(pkgarg) if result == nil { return nil } diff --git a/cmd/lumi/pack_verify.go b/cmd/lumi/pack_verify.go index a30817d6e..bf3ac67bd 100644 --- a/cmd/lumi/pack_verify.go +++ b/cmd/lumi/pack_verify.go @@ -37,8 +37,14 @@ func newPackVerifyCmd() *cobra.Command { // verify creates a compiler, much like compile, but only performs binding and verification on it. If verification // succeeds, the return value is true; if verification fails, errors will have been output, and the return is false. func verify(cmd *cobra.Command, args []string) bool { + var pkgarg string + + if len(args) > 0 { + pkgarg = args[0] + } + // Prepare the compiler info and, provided it succeeds, perform the verification. - if comp, pkg := prepareCompiler(args); comp != nil { + if comp, pkg := prepareCompiler(pkgarg); comp != nil { // Now perform the compilation and extract the heap snapshot. if pkg == nil { return comp.Verify() diff --git a/cmd/lumi/plan.go b/cmd/lumi/plan.go index d97e00eed..73db73e4f 100644 --- a/cmd/lumi/plan.go +++ b/cmd/lumi/plan.go @@ -127,7 +127,7 @@ func plan(info *envCmdInfo, opts deployOptions) (*planResult, error) { } // First, compile the package, in preparatin for interpreting it and creating resources. - result := compile(info.Args) + result := compile(info.PackageArg) if result == nil || !result.B.Ctx().Diag.Success() { return nil, fmt.Errorf("Errors during compilation: %v", result.B.Ctx().Diag.Errors()) }