version_usage.cc 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /* <!-- copyright */
  2. /*
  3. * aria2 - The high speed download utility
  4. *
  5. * Copyright (C) 2006 Tatsuhiro Tsujikawa
  6. *
  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.
  11. *
  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.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. *
  21. * In addition, as a special exception, the copyright holders give
  22. * permission to link the code of portions of this program with the
  23. * OpenSSL library under certain conditions as described in each
  24. * individual source file, and distribute linked combinations
  25. * including the two.
  26. * You must obey the GNU General Public License in all respects
  27. * for all of the code used other than OpenSSL. If you modify
  28. * file(s) with this exception, you may extend this exception to your
  29. * version of the file(s), but you are not obligated to do so. If you
  30. * do not wish to do so, delete this exception statement from your
  31. * version. If you delete this exception statement from all source
  32. * files in the program, then also delete it here.
  33. */
  34. /* copyright --> */
  35. #include "common.h"
  36. #include <iostream>
  37. #include <iterator>
  38. #include <algorithm>
  39. #include "a2io.h"
  40. #include "FeatureConfig.h"
  41. #include "MessageDigest.h"
  42. #include "help_tags.h"
  43. #include "prefs.h"
  44. #include "fmt.h"
  45. #include "OptionParser.h"
  46. #include "OptionHandler.h"
  47. #include "util.h"
  48. namespace aria2 {
  49. void showVersion()
  50. {
  51. std::cout
  52. << PACKAGE << _(" version ") << PACKAGE_VERSION << "\n"
  53. << "Copyright (C) 2006, 2016 Tatsuhiro Tsujikawa"
  54. << "\n"
  55. << "\n"
  56. << _("This program is free software; you can redistribute it and/or "
  57. "modify\n"
  58. "it under the terms of the GNU General Public License as published "
  59. "by\n"
  60. "the Free Software Foundation; either version 2 of the License, or\n"
  61. "(at your option) any later version.\n"
  62. "\n"
  63. "This program is distributed in the hope that it will be useful,\n"
  64. "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
  65. "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
  66. "GNU General Public License for more details.\n")
  67. << "\n"
  68. << _("** Configuration **") << "\n"
  69. << _("Enabled Features") << ": " << featureSummary() << "\n"
  70. << _("Hash Algorithms") << ": "
  71. << MessageDigest::getSupportedHashTypeString() << "\n"
  72. << _("Libraries") << ": " << usedLibs() << "\n"
  73. << _("Compiler") << ": " << usedCompilerAndPlatform() << "\n"
  74. << _("System") << ": " << getOperatingSystemInfo() << "\n"
  75. << "\n"
  76. << fmt(_("Report bugs to %s"), PACKAGE_BUGREPORT) << "\n"
  77. << _("Visit") << " " << PACKAGE_URL << std::endl;
  78. }
  79. void showUsage(const std::string& keyword,
  80. const std::shared_ptr<OptionParser>& oparser, const Console& out)
  81. {
  82. out->printf(_("Usage: aria2c [OPTIONS] [URI | MAGNET | TORRENT_FILE |"
  83. " METALINK_FILE]..."));
  84. out->printf("\n");
  85. if (keyword.empty()) {
  86. // Very short version of usage.
  87. out->printf(_("See 'aria2c -h'."));
  88. out->printf("\n");
  89. return;
  90. }
  91. else if (keyword[0] == '#') {
  92. std::vector<const OptionHandler*> handlers =
  93. keyword == STR_TAG_ALL ? oparser->findAll()
  94. : oparser->findByTag(idHelpTag(keyword.c_str()));
  95. if (keyword == STR_TAG_ALL) {
  96. out->printf(_("Printing all options."));
  97. }
  98. else {
  99. out->printf(_("Printing options tagged with '%s'."), keyword.c_str());
  100. out->printf("\n");
  101. out->printf(_("See 'aria2c -h#help' to know all available tags."));
  102. }
  103. out->printf("\n");
  104. out->printf(_("Options:"));
  105. out->printf("\n");
  106. for (std::vector<const OptionHandler*>::const_iterator i = handlers.begin(),
  107. eoi = handlers.end();
  108. i != eoi; ++i) {
  109. write(out, *(*i));
  110. out->printf("\n");
  111. }
  112. }
  113. else {
  114. std::vector<const OptionHandler*> handlers =
  115. oparser->findByNameSubstring(keyword);
  116. if (!handlers.empty()) {
  117. out->printf(_("Printing options whose name includes '%s'."),
  118. keyword.c_str());
  119. out->printf("\n");
  120. out->printf(_("Options:"));
  121. out->printf("\n");
  122. for (std::vector<const OptionHandler*>::const_iterator
  123. i = handlers.begin(),
  124. eoi = handlers.end();
  125. i != eoi; ++i) {
  126. write(out, *(*i));
  127. out->printf("\n");
  128. }
  129. }
  130. else {
  131. out->printf(_("No option matching with '%s'."), keyword.c_str());
  132. out->printf("\n");
  133. write(out, *oparser->find(PREF_HELP));
  134. }
  135. }
  136. if (keyword == strHelpTag(TAG_BASIC)) {
  137. out->printf("URI, MAGNET, TORRENT_FILE, METALINK_FILE:\n");
  138. out->printf(
  139. _(" You can specify multiple HTTP(S)/FTP URIs. Unless you specify -Z "
  140. "option, all\n"
  141. " URIs must point to the same file or downloading will fail."));
  142. out->printf("\n");
  143. out->printf(_(" You can also specify arbitrary number of BitTorrent Magnet "
  144. "URIs, torrent/\n"
  145. " metalink files stored in a local drive. Please note that "
  146. "they are always\n"
  147. " treated as a separate download."));
  148. out->printf("\n\n");
  149. out->printf(_(" You can specify both torrent file with -T option and URIs. "
  150. "By doing this,\n"
  151. " download a file from both torrent swarm and HTTP/FTP "
  152. "server at the same time,\n"
  153. " while the data from HTTP/FTP are uploaded to the torrent "
  154. "swarm. For single file\n"
  155. " torrents, URI can be a complete URI pointing to the "
  156. "resource or if URI ends\n"
  157. " with '/', 'name' in torrent file is added. For multi-file "
  158. "torrents, 'name' and\n"
  159. " 'path' in torrent are added to form a URI for each file."));
  160. out->printf("\n\n");
  161. out->printf(_(" Make sure that URI is quoted with single(\') or double(\") "
  162. "quotation if it\n"
  163. " contains \"&\" or any characters that have special meaning "
  164. "in shell."));
  165. out->printf("\n\n");
  166. out->printf(
  167. _("About the number of connections\n"
  168. " Since 1.10.0 release, aria2 uses 1 connection per host by default "
  169. "and has 20MiB\n"
  170. " segment size restriction. So whatever value you specify using -s "
  171. "option, it\n"
  172. " uses 1 connection per host. To make it behave like 1.9.x, use\n"
  173. " --max-connection-per-server=4 --min-split-size=1M.\n"
  174. "\n"));
  175. }
  176. out->printf(_("Refer to man page for more information."));
  177. out->printf("\n");
  178. }
  179. } // namespace aria2