Passed
Push — master ( 3b22a1...94154d )
by Tom
03:44
created

Help::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
/* this file is part of pipelines */
4
5
namespace Ktomk\Pipelines\Utility;
6
7
use Ktomk\Pipelines\Cli\Streams;
8
9
class Help
10
{
11
    /**
12
     * @var Streams
13
     */
14
    private $streams;
15
16
    /**
17
     * Help constructor.
18
     * @param Streams $streams
19
     */
20 1
    public function __construct(Streams $streams)
21
    {
22 1
        $this->streams = $streams;
23 1
    }
24
25 1
    public function showVersion()
26
    {
27 1
        $version = Version::resolve(App::VERSION);
28 1
        $this->streams->out(
29 1
            sprintf("pipelines version %s\n", $version)
30
        );
31
32 1
        return 0;
33
    }
34
35 2
    public function showUsage()
36
    {
37 2
        $this->streams->out(
38
            <<<'EOD'
39 2
usage: pipelines [<options>...] [--version | [-h | --help]]
40
       pipelines [-v | --verbose] [--working-dir <path>] [--[no-]keep]
41
                 [--prefix <prefix>] [--basename <basename>]
42
                 [[-e | --env] <variable>] [--env-file <path>]
43
                 [--file <path>] [--dry-run] [--no-run] [--list]
44
                 [--deploy mount | copy ] [--show] [--images]
45
                 [--pipeline <id>] [--trigger <ref>] [--verbatim]
46
       pipelines [-v | --verbose] [--dry-run] [--docker-list]
47
                 [--docker-kill] [--docker-clean]
48
49
EOD
50
        );
51 2
    }
52
53 1
    public function showHelp()
54
    {
55 1
        $this->showUsage();
56 1
        $this->streams->out(
57
            <<<'EOD'
58
59
    -h, --help            show usage and help information
60
    -v, --verbose         show commands executed
61
    --version             show version information only and exit
62
63
Common options
64
    --basename <basename> set basename for pipelines file,
65
                          default is 'bitbucket-pipelines.yml'
66
    --deploy mount|copy   how files from the working directory
67
                          are placed into the pipeline container:
68
                          copy     (default) working dir is
69
                                 copied into the container.
70
                                 stronger isolation as the
71
                                 pipeline scripts can change
72
                                 all files without side-effects
73
                                 in the working directory
74
                          mount    the working directory is
75
                                 mounted. fastest, no isolation
76
    -e, --env <variable>  pass or set an environment variables
77
                          for the docker container
78
    --env-file <path>     pass variables from environment file
79
                          to the docker container
80
    --file <path>         path to the pipelines file, overrides
81
                          looking up the <basename> file from
82
                          the current working directory
83
    --[no-]keep           (do not) keep docker containers.
84
                          default is to kill and remove
85
                          containers after each pipeline step
86
                          unless the pipeline step failed. then
87
                          the non-zero exit status is given and
88
                          an error message showing the container
89
                          id of the kept container
90
    --trigger <ref>       build trigger, <ref> can be of either
91
                          tag:<name>, branch:<name> or
92
                          bookmark:<name>. used in determination
93
                          of the pipeline to run
94
    --pipeline <id>       run pipeline with <id>, see --list
95
    --verbatim            only give verbatim output of the
96
                          pipeline, no other information around
97
                          like which step currently executes
98
    --working-dir <path>  run as if pipelines was started in
99
                          <path>
100
101
Run control options
102
    --dry-run             do not invoke docker or run containers,
103
                          with --verbose shows the commands that
104
                          would have run w/o the --dry-run flag
105
    --no-run              do not run the pipeline
106
107
File information options
108
    --images              list all images in file, in order
109
                          of use, w/o duplicate names and exit
110
    --list                list pipeline <id>s in file and exit
111
    --show                show information about pipelines in
112
                          file and exit
113
114
Docker container maintenance options
115
      usage might leave containers on the system. either by
116
      interrupting a running pipeline step or by keeping the
117
      running containers (--keep).
118
119
      pipelines uses a prefix followed by '-' and a UUID for
120
      container names. the prefix is either 'pipelines' or the
121
      one set by --prefix <prefix>.
122
123
      three options are built-in to monitor and interact with
124
      leftovers. if one or more of these are given, the following
125
      operations are executed in the order from top to down:
126
127
    --docker-list         list prefixed containers
128
    --docker-kill         kills prefixed containers
129
    --docker-clean        remove (non-running) containers with
130
                          pipelines prefix
131
132
Less common options
133
    --debug               flag for trouble-shooting fatal errors
134
    --prefix <prefix>     use a different prefix for container
135
                          names, default is 'pipelines'
136
137
EOD
138
        );
139
140 1
        return 0;
141
    }
142
}
143