comparison cmdline/org/tmatesoft/hg/console/Status.java @ 299:45dc79e545f5

Recognize flag options (options with no arguments) in command line sample apps
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Sat, 17 Sep 2011 13:26:52 +0200
parents 23e3ea855097
children 150500515714
comparison
equal deleted inserted replaced
298:aac0c3fab6ce 299:45dc79e545f5
14 * the terms of a license other than GNU General Public License 14 * the terms of a license other than GNU General Public License
15 * contact TMate Software at support@hg4j.com 15 * contact TMate Software at support@hg4j.com
16 */ 16 */
17 package org.tmatesoft.hg.console; 17 package org.tmatesoft.hg.console;
18 18
19 import static org.tmatesoft.hg.console.Options.asSet;
19 import static org.tmatesoft.hg.repo.HgRepository.BAD_REVISION; 20 import static org.tmatesoft.hg.repo.HgRepository.BAD_REVISION;
20 21
21 import java.util.ArrayList; 22 import java.util.ArrayList;
22 import java.util.Collections; 23 import java.util.Collections;
23 import java.util.EnumMap; 24 import java.util.EnumMap;
24 import java.util.HashMap; 25 import java.util.HashMap;
25 import java.util.LinkedList; 26 import java.util.LinkedList;
26 import java.util.List; 27 import java.util.List;
27 import java.util.Map; 28 import java.util.Map;
29 import java.util.Set;
28 30
29 import org.tmatesoft.hg.core.HgRepoFacade; 31 import org.tmatesoft.hg.core.HgRepoFacade;
30 import org.tmatesoft.hg.core.HgStatus; 32 import org.tmatesoft.hg.core.HgStatus;
31 import org.tmatesoft.hg.core.HgStatus.Kind; 33 import org.tmatesoft.hg.core.HgStatus.Kind;
32 import org.tmatesoft.hg.core.HgStatusCommand; 34 import org.tmatesoft.hg.core.HgStatusCommand;
38 * @author TMate Software Ltd. 40 * @author TMate Software Ltd.
39 */ 41 */
40 public class Status { 42 public class Status {
41 43
42 public static void main(String[] args) throws Exception { 44 public static void main(String[] args) throws Exception {
43 Options cmdLineOpts = Options.parse(args); 45 final Set<String> flagOpts = asSet("-A", "-all", "-m", "--modified", "-a", "--added", "-r", "--removed",
46 "--d", "--deleted", "-u", "--unknown", "-c", "--clean", "-i", "--ignored",
47 "-n", "--no-status", "-C", "--copies");
48 Options cmdLineOpts = Options.parse(args, flagOpts);
44 HgRepoFacade hgRepo = new HgRepoFacade(); 49 HgRepoFacade hgRepo = new HgRepoFacade();
45 if (!hgRepo.init(cmdLineOpts.findRepository())) { 50 if (!hgRepo.init(cmdLineOpts.findRepository())) {
46 System.err.printf("Can't find repository in: %s\n", hgRepo.getRepository().getLocation()); 51 System.err.printf("Can't find repository in: %s\n", hgRepo.getRepository().getLocation());
47 return; 52 return;
48 } 53 }