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

Side by Side Diff: vpython/application/support.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/vpython/python"
9
10 "github.com/luci/luci-go/common/errors"
11
12 "golang.org/x/net/context"
13 )
14
15 var appKey = "github.com/luci/luci-go/vpython/application.A"
16
17 func withApplication(c context.Context, a *A) context.Context {
18 return context.WithValue(c, &appKey, a)
19 }
20
21 func getApplication(c context.Context) *A {
22 return c.Value(&appKey).(*A)
23 }
24
25 func run(c context.Context, fn func(context.Context) error) int {
26 err := fn(c)
27
28 switch t := errors.Unwrap(err).(type) {
29 case nil:
30 return 0
31
32 case python.Error:
33 return int(t)
34
35 default:
36 errors.Log(c, err)
37 return 1
38 }
39 }
OLDNEW
« vpython/application/application.go ('K') | « vpython/application/subcommand_install.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698