Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Unified Diff: vpython/application/subcommand_install.go

Issue 2705593003: vpython: Add application entry point. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: vpython/application/subcommand_install.go
diff --git a/vpython/application/subcommand_install.go b/vpython/application/subcommand_install.go
new file mode 100644
index 0000000000000000000000000000000000000000..98a09d38d81c030df75ee503adb10358682dbad3
--- /dev/null
+++ b/vpython/application/subcommand_install.go
@@ -0,0 +1,47 @@
+// Copyright 2017 The LUCI Authors. All rights reserved.
+// Use of this source code is governed under the Apache License, Version 2.0
+// that can be found in the LICENSE file.
+
+package application
+
+import (
+ "github.com/luci/luci-go/common/cli"
+ "github.com/luci/luci-go/common/errors"
+ "github.com/luci/luci-go/common/logging"
+
+ "github.com/maruel/subcommands"
+ "golang.org/x/net/context"
+)
+
+var subcommandInstall = &subcommands.Command{
+ UsageLine: "install",
+ ShortDesc: "installs the configured VirtualEnv",
+ LongDesc: "installs the configured VirtualEnv, but doesn't run any associated commands",
+ Advanced: false,
+ CommandRun: func() subcommands.CommandRun {
+ return &installCommandRun{}
+ },
+}
+
+type installCommandRun struct {
+ subcommands.CommandRunBase
+}
+
+func (cr *installCommandRun) Run(app subcommands.Application, args []string, env subcommands.Env) int {
+ c := cli.GetContext(app, cr, env)
+ a := getApplication(c)
+
+ return run(c, func(c context.Context) error {
+ env, err := a.Opts.EnvConfig.Env(c)
+ if err != nil {
+ return errors.Annotate(err).Reason("failed to configure environment").Err()
+ }
+
+ if err := env.Setup(c, false); err != nil {
+ return errors.Annotate(err).Reason("failed to setup the environment").Err()
+ }
+
+ logging.Infof(c, "Successfully setup the enviornment.")
+ return nil
+ })
+}

Powered by Google App Engine
This is Rietveld 408576698