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

Side by Side Diff: vpython/application/support.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 unified diff | Download patch
« no previous file with comments | « vpython/application/subcommand_install.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/errors"
9
10 "golang.org/x/net/context"
11 )
12
13 var appKey = "github.com/luci/luci-go/vpython/application.A"
14
15 func withConfig(c context.Context, cfg *Config) context.Context {
16 return context.WithValue(c, &appKey, cfg)
17 }
18
19 func getConfig(c context.Context) *Config {
20 return c.Value(&appKey).(*Config)
21 }
22
23 func run(c context.Context, fn func(context.Context) error) int {
24 err := fn(c)
25
26 switch t := errors.Unwrap(err).(type) {
27 case nil:
28 return 0
29
30 case ReturnCodeError:
31 return int(t)
32
33 default:
34 errors.Log(c, err)
35 return 1
36 }
37 }
OLDNEW
« no previous file with comments | « vpython/application/subcommand_install.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698