View Javadoc

1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.cli2.application;
18  
19  import junit.framework.TestCase;
20  
21  import org.apache.commons.cli2.Group;
22  import org.apache.commons.cli2.builder.ArgumentBuilder;
23  import org.apache.commons.cli2.builder.CommandBuilder;
24  import org.apache.commons.cli2.builder.DefaultOptionBuilder;
25  import org.apache.commons.cli2.builder.GroupBuilder;
26  import org.apache.commons.cli2.option.ArgumentTest;
27  
28  //TODO Build up CvsTest like CpTest
29  public class CvsTest extends TestCase {
30      public void testCVS() {
31          final DefaultOptionBuilder obuilder = new DefaultOptionBuilder();
32          final ArgumentBuilder abuilder = new ArgumentBuilder();
33          final CommandBuilder cbuilder = new CommandBuilder();
34          final GroupBuilder gbuilder = new GroupBuilder();
35  
36          final Group commands =
37              gbuilder
38                  .withName("commands")
39                  .withOption(
40                      cbuilder
41                          .withName("add")
42                          .withName("ad")
43                          .withName("new")
44                          .withDescription("Add a new file/directory to the repository")
45                          .create())
46                  .withOption(
47                      cbuilder
48                          .withName("admin")
49                          .withName("adm")
50                          .withName("rcs")
51                          .withDescription("Administration front end for rcs")
52                          .create())
53                  .withOption(
54                      cbuilder
55                          .withName("annotate")
56                          .withName("ann")
57                          .withDescription("Show last revision where each line was modified")
58                          .create())
59                  .withOption(
60                      cbuilder
61                          .withName("checkout")
62                          .withName("co")
63                          .withName("get")
64                          .withDescription("Checkout sources for editing")
65                          .create())
66                  .withOption(
67                      cbuilder
68                          .withName("commit")
69                          .withName("ci")
70                          .withName("com")
71                          .withDescription("Check files into the repository")
72                          .create())
73                  .withOption(
74                      cbuilder
75                          .withName("diff")
76                          .withName("di")
77                          .withName("dif")
78                          .withDescription("Show differences between revisions")
79                          .create())
80                  .withOption(
81                      cbuilder
82                          .withName("edit")
83                          .withDescription("Get ready to edit a watched file")
84                          .create())
85                  .withOption(
86                      cbuilder
87                          .withName("editors")
88                          .withDescription("See who is editing a watched file")
89                          .create())
90                  .withOption(
91                      cbuilder
92                          .withName("export")
93                          .withName("exp")
94                          .withName("ex")
95                          .withDescription("Export sources from CVS, similar to checkout")
96                          .create())
97                  .withOption(
98                      cbuilder
99                          .withName("history")
100                         .withName("hi")
101                         .withName("his")
102                         .withDescription("Show repository access history")
103                         .create())
104                 .withOption(
105                     cbuilder
106                         .withName("import")
107                         .withName("im")
108                         .withName("imp")
109                         .withDescription("Import sources into CVS, using vendor branches")
110                         .create())
111                 .withOption(
112                     cbuilder
113                         .withName("init")
114                         .withDescription("Create a CVS repository if it doesn't exist")
115                         .create())
116                 .withOption(
117                     cbuilder
118                         .withName("log")
119                         .withName("lo")
120                         .withName("rlog")
121                         .withDescription("Print out history information for files")
122                         .create())
123                 .withOption(
124                     cbuilder
125                         .withName("login")
126                         .withName("logon")
127                         .withName("lgn")
128                         .withDescription("Prompt for password for authenticating server")
129                         .create())
130                 .withOption(
131                     cbuilder
132                         .withName("logout")
133                         .withDescription("Removes entry in .cvspass for remote repository")
134                         .create())
135                 .withOption(
136                     cbuilder
137                         .withName("rdiff")
138                         .withName("patch")
139                         .withName("pa")
140                         .withDescription("Create 'patch' format diffs between releases")
141                         .create())
142                 .withOption(
143                     cbuilder
144                         .withName("release")
145                         .withName("re")
146                         .withName("rel")
147                         .withDescription("Indicate that a Module is no longer in use")
148                         .create())
149                 .withOption(
150                     cbuilder
151                         .withName("remove")
152                         .withName("rm")
153                         .withName("delete")
154                         .withDescription("Remove an entry from the repository")
155                         .create())
156                 .withOption(
157                     cbuilder
158                         .withName("rtag")
159                         .withName("rt")
160                         .withName("rfreeze")
161                         .withDescription("Add a symbolic tag to a module")
162                         .create())
163                 .withOption(
164                     cbuilder
165                         .withName("status")
166                         .withName("st")
167                         .withName("stat")
168                         .withDescription("Display status information on checked out files")
169                         .create())
170                 .withOption(
171                     cbuilder
172                         .withName("tag")
173                         .withName("ta")
174                         .withName("freeze")
175                         .withDescription("Add a symbolic tag to checked out version of files")
176                         .create())
177                 .withOption(
178                     cbuilder
179                         .withName("unedit")
180                         .withDescription("Undo an edit command")
181                         .create())
182                 .withOption(
183                     cbuilder
184                         .withName("update")
185                         .withName("up")
186                         .withName("upd")
187                         .withDescription("Bring work tree in sync with repository")
188                         .create())
189                 .withOption(
190                     cbuilder
191                         .withName("watch")
192                         .withDescription("Set watches")
193                         .create())
194                 .withOption(
195                     cbuilder
196                         .withName("watchers")
197                         .withDescription("See who is watching a file")
198                         .create())
199                 .withOption(
200                     cbuilder
201                         .withName("version")
202                         .withName("ve")
203                         .withName("ver")
204                         .withDescription("????")
205                         .create())
206                 .withOption(ArgumentTest.buildTargetsArgument())
207                 .create();
208 
209         final Group cvsOptions =
210             new GroupBuilder()
211                 .withName("cvs-options")
212                 .withOption(
213                     obuilder
214                         .withShortName("H")
215                         .withDescription("Displays usage information for command.")
216                         .create())
217                 .withOption(
218                     obuilder
219                         .withShortName("Q")
220                         .withDescription("Cause CVS to be really quiet.")
221                         .create())
222                 .withOption(
223                     obuilder
224                         .withShortName("q")
225                         .withDescription("Cause CVS to be somewhat quiet.")
226                         .create())
227                 .withOption(
228                     obuilder
229                         .withShortName("r")
230                         .withDescription("Make checked-out files read-only.")
231                         .create())
232                 .withOption(
233                     obuilder
234                         .withShortName("w")
235                         .withDescription("Make checked-out files read-write (default).")
236                         .create())
237                 .withOption(
238                     obuilder
239                         .withShortName("l")
240                         .withDescription("Turn history logging off.")
241                         .create())
242                 .withOption(
243                     obuilder
244                         .withShortName("n")
245                         .withDescription("Do not execute anything that will change the disk.")
246                         .create())
247                 .withOption(
248                     obuilder
249                         .withShortName("t")
250                         .withDescription("Show trace of program execution -- try with -n.")
251                         .create())
252                 .withOption(
253                     obuilder
254                         .withShortName("v")
255                         .withDescription("CVS version and copyright.")
256                         .create())
257                 .withOption(
258                     obuilder
259                         .withLongName("crlf")
260                         .withDescription("Use the Dos line feed for text files (default).")
261                         .create())
262                 .withOption(
263                     obuilder
264                         .withLongName("lf")
265                         .withDescription("Use the Unix line feed for text files.")
266                         .create())
267                 .withOption(
268                     obuilder
269                         .withShortName("T")
270                         .withDescription("Use 'tmpdir' for temporary files.")
271                         .withArgument(abuilder.withName("tmpdir").create())
272                         .create())
273                 .withOption(
274                     obuilder
275                         .withShortName("e")
276                         .withDescription("Use 'editor' for editing log information.")
277                         .withArgument(abuilder.withName("editor").create())
278                         .create())
279                 .withOption(
280                     obuilder
281                         .withShortName("d")
282                         .withDescription("Overrides $CVSROOT as the root of the CVS tree.")
283                         .withArgument(abuilder.withName("CVS_root").create())
284                         .create())
285                 .withOption(
286                     obuilder
287                         .withShortName("f")
288                         .withDescription("Do not use the ~/.cvsrc file.")
289                         .create())
290                 .withOption(
291                     obuilder
292                         .withShortName("z")
293                         .withDescription("Use compression level '#' for net traffic.")
294                         .withArgument(abuilder.withName("#").create())
295                         .create())
296                 .withOption(
297                     obuilder
298                         .withShortName("a")
299                         .withDescription("Authenticate all net traffic.")
300                         .create())
301                 .withOption(
302                     obuilder
303                         .withShortName("s")
304                         .withDescription("Set CVS user variable.")
305                         .withArgument(abuilder.withName("VAR=VAL").create())
306                         .create())
307                 .withOption(commands)
308                 .create();
309 
310         assertNotNull(cvsOptions);
311     }
312 }