1
2
3
4
5
6
7
8
9
10 package org.eclipse.jgit.pgm.opt;
11
12 import org.eclipse.jgit.pgm.internal.CLIText;
13 import org.kohsuke.args4j.CmdLineException;
14 import org.kohsuke.args4j.CmdLineParser;
15 import org.kohsuke.args4j.OptionDef;
16 import org.kohsuke.args4j.spi.Parameters;
17 import org.kohsuke.args4j.spi.Setter;
18 import org.kohsuke.args4j.spi.StringOptionHandler;
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 public class UntrackedFilesHandler extends StringOptionHandler {
39
40
41
42
43
44
45
46
47
48
49
50 public UntrackedFilesHandler(CmdLineParser parser, OptionDef option,
51 Setter<? super String> setter) {
52 super(parser, option, setter);
53 }
54
55
56 @Override
57 public int parseArguments(Parameters params) throws CmdLineException {
58 String alias = params.getParameter(-1);
59 if ("-u".equals(alias)) {
60 setter.addValue("all");
61 return 0;
62 } else if ("-uno".equals(alias)) {
63 setter.addValue("no");
64 return 0;
65 } else if ("-uall".equals(alias)) {
66 setter.addValue("all");
67 return 0;
68 } else if (params.size() == 0) {
69 setter.addValue("all");
70 return 0;
71 } else if (params.size() == 1) {
72 String mode = params.getParameter(0);
73 if ("no".equals(mode) || "all".equals(mode)) {
74 setter.addValue(mode);
75 } else {
76 throw new CmdLineException(owner,
77 CLIText.format(CLIText.get().invalidUntrackedFilesMode),
78 mode);
79 }
80 return 1;
81 } else {
82 return super.parseArguments(params);
83 }
84 }
85
86 }