001/** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.cli2.application; 018 019import junit.framework.TestCase; 020 021import org.apache.commons.cli2.Group; 022import org.apache.commons.cli2.builder.ArgumentBuilder; 023import org.apache.commons.cli2.builder.CommandBuilder; 024import org.apache.commons.cli2.builder.DefaultOptionBuilder; 025import org.apache.commons.cli2.builder.GroupBuilder; 026import org.apache.commons.cli2.option.ArgumentTest; 027 028//TODO Build up CvsTest like CpTest 029public class CvsTest extends TestCase { 030 public void testCVS() { 031 final DefaultOptionBuilder obuilder = new DefaultOptionBuilder(); 032 final ArgumentBuilder abuilder = new ArgumentBuilder(); 033 final CommandBuilder cbuilder = new CommandBuilder(); 034 final GroupBuilder gbuilder = new GroupBuilder(); 035 036 final Group commands = 037 gbuilder 038 .withName("commands") 039 .withOption( 040 cbuilder 041 .withName("add") 042 .withName("ad") 043 .withName("new") 044 .withDescription("Add a new file/directory to the repository") 045 .create()) 046 .withOption( 047 cbuilder 048 .withName("admin") 049 .withName("adm") 050 .withName("rcs") 051 .withDescription("Administration front end for rcs") 052 .create()) 053 .withOption( 054 cbuilder 055 .withName("annotate") 056 .withName("ann") 057 .withDescription("Show last revision where each line was modified") 058 .create()) 059 .withOption( 060 cbuilder 061 .withName("checkout") 062 .withName("co") 063 .withName("get") 064 .withDescription("Checkout sources for editing") 065 .create()) 066 .withOption( 067 cbuilder 068 .withName("commit") 069 .withName("ci") 070 .withName("com") 071 .withDescription("Check files into the repository") 072 .create()) 073 .withOption( 074 cbuilder 075 .withName("diff") 076 .withName("di") 077 .withName("dif") 078 .withDescription("Show differences between revisions") 079 .create()) 080 .withOption( 081 cbuilder 082 .withName("edit") 083 .withDescription("Get ready to edit a watched file") 084 .create()) 085 .withOption( 086 cbuilder 087 .withName("editors") 088 .withDescription("See who is editing a watched file") 089 .create()) 090 .withOption( 091 cbuilder 092 .withName("export") 093 .withName("exp") 094 .withName("ex") 095 .withDescription("Export sources from CVS, similar to checkout") 096 .create()) 097 .withOption( 098 cbuilder 099 .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}