1
2
3
4
5
6
7
8
9
10
11
12 package org.jenkinsci.plugins.darcs.cmd;
13
14 import hudson.util.ArgumentListBuilder;
15 import org.apache.commons.lang.Validate;
16
17
18
19
20
21
22
23
24 public class DarcsPullBuilder extends DarcsBaseCommandBuilder implements DarcsCommandCreator {
25
26
27
28
29 private static final String COMMAND = "pull";
30
31
32
33 private String from = "";
34
35
36
37 private String repoDir = "";
38
39
40
41 private boolean all;
42
43
44
45 private boolean verbose;
46
47
48
49
50
51
52 DarcsPullBuilder(final String darcsExe) {
53 super(darcsExe, COMMAND);
54 }
55
56
57
58
59
60
61
62
63
64
65 public DarcsPullBuilder from(final String location) {
66 Validate.notEmpty(location);
67 from = location;
68 return this;
69 }
70
71
72
73
74
75
76
77
78
79
80 public DarcsPullBuilder repoDir(final String directory) {
81 Validate.notEmpty(directory);
82 repoDir = directory;
83 return this;
84 }
85
86
87
88
89
90
91 public DarcsPullBuilder all() {
92 all = true;
93 return this;
94 }
95
96
97
98
99
100
101 public DarcsPullBuilder verbose() {
102 verbose = true;
103 return this;
104 }
105
106 @Override
107 public DarcsCommand create() {
108 Validate.notEmpty(from, "Set from where to pull the patches!");
109 final ArgumentListBuilder arguments = createArgumentList();
110 arguments.add(from);
111
112 if (repoDir.length() > 0) {
113 arguments.add(String.format("--repo=%s", repoDir));
114 }
115
116 if (all) {
117 arguments.add("--all");
118 }
119
120 if (verbose) {
121 arguments.add("--verbose");
122 }
123
124 return new DarcsCommand(arguments);
125 }
126
127 }