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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file.
4
5 package application
6
7 import (
8 "github.com/luci/luci-go/common/cli"
9 "github.com/luci/luci-go/common/errors"
10 "github.com/luci/luci-go/common/logging"
11
12 "github.com/maruel/subcommands"
13 "golang.org/x/net/context"
14 )
15
16 var subcommandInstall = &subcommands.Command{
17 UsageLine: "install",
18 ShortDesc: "installs the configured VirtualEnv",
19 LongDesc: "installs the configured VirtualEnv, but doesn't run any asso ciated commands",
20 Advanced: false,
21 CommandRun: func() subcommands.CommandRun {
22 return &installCommandRun{}
23 },
24 }
25
26 type installCommandRun struct {
27 subcommands.CommandRunBase
28 }
29
30 func (cr *installCommandRun) Run(app subcommands.Application, args []string, env subcommands.Env) int {
31 c := cli.GetContext(app, cr, env)
32 a := getApplication(c)
33
34 return run(c, func(c context.Context) error {
35 env, err := a.Opts.EnvConfig.Env(c)
36 if err != nil {
37 return errors.Annotate(err).Reason("failed to configure environment").Err()
38 }
39
40 if err := env.Setup(c, false); err != nil {
41 return errors.Annotate(err).Reason("failed to setup the environment").Err()
42 }
43
44 logging.Infof(c, "Successfully setup the enviornment.")
45 return nil
46 })
47 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698