]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.core/src/org/argeo/sync/cli/Sync.java
1 package org
.argeo
.sync
.cli
;
4 import java
.nio
.file
.Paths
;
7 import org
.apache
.commons
.cli
.CommandLine
;
8 import org
.apache
.commons
.cli
.CommandLineParser
;
9 import org
.apache
.commons
.cli
.DefaultParser
;
10 import org
.apache
.commons
.cli
.HelpFormatter
;
11 import org
.apache
.commons
.cli
.Option
;
12 import org
.apache
.commons
.cli
.Options
;
13 import org
.argeo
.sync
.fs
.PathSync
;
17 public static void main(String
[] args
) {
18 Options options
= new Options();
19 options
.addOption("r", "recursive", false, "recurse into directories");
20 options
.addOption(Option
.builder().longOpt("progress").hasArg(false).desc("show progress").build());
22 CommandLineParser parser
= new DefaultParser();
24 CommandLine line
= parser
.parse(options
, args
);
25 List
<String
> remaining
= line
.getArgList();
26 if (remaining
.size() == 0) {
27 System
.err
.println("There must be at least one argument");
31 URI sourceUri
= new URI(remaining
.get(0));
33 if (remaining
.size() == 1) {
34 targetUri
= Paths
.get(System
.getProperty("user.dir")).toUri();
36 targetUri
= new URI(remaining
.get(1));
38 PathSync pathSync
= new PathSync(sourceUri
, targetUri
);
40 } catch (Exception exp
) {
41 exp
.printStackTrace();
47 public static void printHelp(Options options
) {
48 HelpFormatter formatter
= new HelpFormatter();
49 formatter
.printHelp("sync SRC [DEST]", options
, true);