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

Unified Diff: vpython/application/subcommand_install.go

Issue 2705593003: vpython: Add application entry point. (Closed)
Patch Set: rebarse? Created 3 years, 9 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
« no previous file with comments | « vpython/application/application.go ('k') | vpython/application/support.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..c8e58dccd5d1aaf8ba1dde088f2a9907343bcd08
--- /dev/null
+++ b/vpython/application/subcommand_install.go
@@ -0,0 +1,46 @@
+// 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/luci/luci-go/vpython/venv"
+
+ "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)
+ cfg := getConfig(c)
+
+ return run(c, func(c context.Context) error {
+ err := venv.With(c, cfg.Opts.EnvConfig, false, func(context.Context, *venv.Env) error {
+ return nil
+ })
+ if err != nil {
+ return errors.Annotate(err).Reason("failed to setup the environment").Err()
+ }
+
+ logging.Infof(c, "Successfully setup the enviornment.")
+ return nil
+ })
+}
« no previous file with comments | « vpython/application/application.go ('k') | vpython/application/support.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698