This repository was archived by the owner on Sep 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcommands.go
102 lines (95 loc) · 2.22 KB
/
commands.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//
// commands.go
//
// Copyright (c) 2016-2017 Junpei Kawamoto
//
// This software is released under the MIT License.
//
// http://opensource.org/licenses/mit-license.php
//
package main
import (
"fmt"
"os"
"runtime"
"github.com/urfave/cli"
)
// max returns the bigger value of the given two integers.
func max(a, b int) int {
if a > b {
return a
}
return b
}
// GlobalFlags defines global flags.
var GlobalFlags = []cli.Flag{
cli.StringFlag{
Name: "name, n",
Usage: "base `NAME` of containers running tests. " +
"If not given, containers will be deleted.",
},
cli.StringFlag{
Name: "select, s",
Usage: "select specific runtime `VERSION` where tests running on.",
},
cli.StringFlag{
Name: "tag, t",
Usage: "specify a `TAG` name of the docker image to be build.",
},
cli.IntFlag{
Name: "max-processors, p",
Usage: "max processors used to run tests.",
Value: max(runtime.NumCPU()-2, 1),
},
cli.BoolFlag{
Name: "log, l",
Usage: "store logging information to files.",
},
cli.StringFlag{
Name: "base, b",
Usage: "use image `TAG` as the base image.",
Value: "ubuntu:trusty",
},
cli.StringFlag{
Name: "apt-proxy",
Usage: "`URL` for a proxy server of apt repository.",
EnvVar: "APT_PROXY",
},
cli.StringFlag{
Name: "pypi-proxy",
Usage: "`URL` for a proxy server of pypi repository.",
EnvVar: "PYPI_PROXY",
},
cli.StringFlag{
Name: "http-proxy",
Usage: "`URL` for a http proxy server.",
EnvVar: "HTTP_PROXY",
},
cli.StringFlag{
Name: "https-proxy",
Usage: "`URL` for a https proxy server.",
EnvVar: "HTTPS_PROXY",
},
cli.StringFlag{
Name: "no-proxy",
Usage: "Comma separated URL `LIST` for which proxies won't be used.",
EnvVar: "NO_PROXY",
},
cli.BoolFlag{
Name: "no-build-cache",
Usage: "Do not use cache when building the image.",
},
cli.BoolFlag{
Name: "no-color",
Usage: "Omit to print color codes.",
},
}
// Commands defines sub-commands.
var Commands = []cli.Command{}
// CommandNotFound prints an error message when a given command is not supported.
func CommandNotFound(c *cli.Context, command string) {
fmt.Fprintf(
os.Stderr, "%s: '%s' is not a %s command. See '%s --help'.",
c.App.Name, command, c.App.Name, c.App.Name)
os.Exit(2)
}