Mercurial > jhg
comparison cmdline/org/tmatesoft/hg/console/Log.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 | 4c3b9f679412 |
children | 31a89587eb04 |
comparison
equal
deleted
inserted
replaced
298:aac0c3fab6ce | 299:45dc79e545f5 |
---|---|
13 * For information on how to redistribute this software under | 13 * For information on how to redistribute this software under |
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 | |
19 import static org.tmatesoft.hg.console.Options.asSet; | |
18 | 20 |
19 import java.util.List; | 21 import java.util.List; |
20 | 22 |
21 import org.tmatesoft.hg.core.HgFileRevision; | 23 import org.tmatesoft.hg.core.HgFileRevision; |
22 import org.tmatesoft.hg.core.HgLogCommand; | 24 import org.tmatesoft.hg.core.HgLogCommand; |
33 public class Log { | 35 public class Log { |
34 | 36 |
35 // -agentlib:hprof=heap=sites,depth=10,etc might be handy to debug speed/memory issues | 37 // -agentlib:hprof=heap=sites,depth=10,etc might be handy to debug speed/memory issues |
36 | 38 |
37 public static void main(String[] args) throws Exception { | 39 public static void main(String[] args) throws Exception { |
38 Options cmdLineOpts = Options.parse(args); | 40 Options cmdLineOpts = Options.parse(args, asSet("--debug", "-v", "--verbose", "--hg4j-order-direct")); |
39 HgRepository hgRepo = cmdLineOpts.findRepository(); | 41 HgRepository hgRepo = cmdLineOpts.findRepository(); |
40 if (hgRepo.isInvalid()) { | 42 if (hgRepo.isInvalid()) { |
41 System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation()); | 43 System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation()); |
42 return; | 44 return; |
43 } | 45 } |
47 final ProgressSupport noProgress = ProgressSupport.Factory.get(null); | 49 final ProgressSupport noProgress = ProgressSupport.Factory.get(null); |
48 // | 50 // |
49 final Dump dump = new Dump(hgRepo); | 51 final Dump dump = new Dump(hgRepo); |
50 dump.complete(cmdLineOpts.getBoolean("--debug")); | 52 dump.complete(cmdLineOpts.getBoolean("--debug")); |
51 dump.verbose(cmdLineOpts.getBoolean("-v", "--verbose")); | 53 dump.verbose(cmdLineOpts.getBoolean("-v", "--verbose")); |
52 final boolean reverseOrder = true; | 54 final boolean reverseOrder = !cmdLineOpts.getBoolean("--hg4j-order-direct"); |
53 dump.reversed(reverseOrder); | 55 dump.reversed(reverseOrder); |
54 HgLogCommand cmd = new HgLogCommand(hgRepo); | 56 HgLogCommand cmd = new HgLogCommand(hgRepo); |
55 for (String u : cmdLineOpts.getList("-u", "--user")) { | 57 for (String u : cmdLineOpts.getList("-u", "--user")) { |
56 cmd.user(u); | 58 cmd.user(u); |
57 } | 59 } |