1 package ch
.cyberduck
.cli
;
4 * Copyright (c) 2002-2014 David Kocher. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * Bug fixes, suggestions and comments should be sent to:
18 * feedback@cyberduck.io
21 import ch
.cyberduck
.core
.Local
;
22 import ch
.cyberduck
.core
.LocalFactory
;
23 import ch
.cyberduck
.core
.Protocol
;
24 import ch
.cyberduck
.core
.ProtocolFactory
;
25 import ch
.cyberduck
.core
.aquaticprime
.License
;
26 import ch
.cyberduck
.core
.aquaticprime
.LicenseFactory
;
27 import ch
.cyberduck
.core
.preferences
.Preferences
;
28 import ch
.cyberduck
.core
.preferences
.PreferencesFactory
;
30 import org
.apache
.commons
.cli
.HelpFormatter
;
31 import org
.apache
.commons
.cli
.Options
;
32 import org
.apache
.commons
.lang3
.StringUtils
;
34 import java
.text
.MessageFormat
;
39 public final class TerminalHelpPrinter
{
41 private TerminalHelpPrinter() {
45 public static void print(final Options options
) {
46 print(options
, new TerminalHelpFormatter());
49 public static void print(final Options options
, final HelpFormatter formatter
) {
50 formatter
.setSyntaxPrefix("Usage:");
51 final StringBuilder protocols
= new StringBuilder(StringUtils
.LF
);
52 protocols
.append("Supported protocols");
53 protocols
.append(StringUtils
.LF
);
54 for(Protocol p
: ProtocolFactory
.getEnabledProtocols()) {
55 protocols
.append(p
.getProvider()).append("\t").append(p
.getDescription());
56 protocols
.append(StringUtils
.LF
);
62 protocols
.append("\t").append(String
.format("%s://<container>/<key>", p
.getProvider()));
65 protocols
.append("\t").append(String
.format("%s://<hostname>/<folder>/<file>", p
.getProvider()));
68 protocols
.append(StringUtils
.LF
);
70 final StringBuilder header
= new StringBuilder(StringUtils
.LF
);
72 header
.append("URLs must be fully qualified. Paths can either denote "
73 + "a remote file (ftps://user@example.net/resource) or folder (ftps://user@example.net/directory/) "
74 + "with a trailing slash. You can reference files relative to your home directory with /~ (ftps://user@example.net/~/).");
75 header
.append(protocols
.toString());
76 final Preferences preferences
= PreferencesFactory
.get();
77 final Local profiles
= LocalFactory
.get(preferences
.getProperty("application.support.path"),
78 PreferencesFactory
.get().getProperty("profiles.folder.name"));
79 header
.append(StringUtils
.LF
);
80 header
.append(String
.format("You can install additional connection profiles in %s",
81 profiles
.getAbbreviatedPath()));
82 header
.append(StringUtils
.LF
);
83 final StringBuilder footer
= new StringBuilder(StringUtils
.LF
);
84 footer
.append(String
.format("Cyberduck is libre software licenced under the GPL. For general help about using Cyberduck, please refer to %s and the wiki at %s. For bug reports or feature requests open a ticket at %s.",
85 preferences
.getProperty("website.cli"), preferences
.getProperty("website.help"), MessageFormat
.format(preferences
.getProperty("website.bug"), preferences
.getProperty("application.version"))));
86 final License l
= LicenseFactory
.find();
87 footer
.append(StringUtils
.LF
);
89 footer
.append(l
.toString());
92 footer
.append("Not registered. Purchase a donation key to support the development of this software.");
94 formatter
.printHelp("duck [options...]", header
.toString(), options
, footer
.toString());