version_usage.cc 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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 "SharedHandle.h"
  40. #include "a2io.h"
  41. #include "FeatureConfig.h"
  42. #ifdef ENABLE_MESSAGE_DIGEST
  43. # include "MessageDigest.h"
  44. #endif // ENABLE_MESSAGE_DIGEST
  45. #include "help_tags.h"
  46. #include "prefs.h"
  47. #include "fmt.h"
  48. #include "OptionParser.h"
  49. #include "OptionHandler.h"
  50. #include "util.h"
  51. namespace aria2 {
  52. void showVersion() {
  53. std::cout << PACKAGE << _(" version ") << PACKAGE_VERSION << "\n"
  54. << "Copyright (C) 2006, 2012 Tatsuhiro Tsujikawa" << "\n"
  55. << "\n"
  56. <<
  57. _("This program is free software; you can redistribute it and/or modify\n"
  58. "it under the terms of the GNU General Public License as published by\n"
  59. "the Free Software Foundation; either version 2 of the License, or\n"
  60. "(at your option) any later version.\n"
  61. "\n"
  62. "This program is distributed in the hope that it will be useful,\n"
  63. "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
  64. "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
  65. "GNU General Public License for more details.\n")
  66. << "\n"
  67. << _("** Configuration **") << "\n"
  68. << _("Enabled Features") << ": "
  69. << featureSummary() << "\n"
  70. #ifdef ENABLE_MESSAGE_DIGEST
  71. << _("Hash Algorithms") << ": "
  72. << MessageDigest::getSupportedHashTypeString() << "\n"
  73. #endif // ENABLE_MESSAGE_DIGEST
  74. << "\n"
  75. << fmt(_("Report bugs to %s"), PACKAGE_BUGREPORT) << "\n"
  76. << _("Visit") << " " << PACKAGE_URL << std::endl;
  77. }
  78. void showUsage
  79. (const std::string& keyword,
  80. const SharedHandle<OptionParser>& oparser,
  81. const Console& out) {
  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. } else if(keyword[0] == '#') {
  91. std::vector<SharedHandle<OptionHandler> > handlers =
  92. keyword == STR_TAG_ALL ? oparser->findAll() :
  93. oparser->findByTag(idHelpTag(keyword.c_str()));
  94. if(keyword == STR_TAG_ALL) {
  95. out->printf(_("Printing all options."));
  96. } else {
  97. out->printf(_("Printing options tagged with '%s'."),
  98. keyword.c_str());
  99. out->printf("\n");
  100. out->printf(_("See 'aria2c -h#help' to know all available tags."));
  101. }
  102. out->printf("\n");
  103. out->printf(_("Options:"));
  104. out->printf("\n");
  105. for(std::vector<SharedHandle<OptionHandler> >::const_iterator i =
  106. handlers.begin(), eoi = handlers.end(); i != eoi; ++i) {
  107. write(out, *(*i));
  108. out->printf("\n");
  109. }
  110. } else {
  111. std::vector<SharedHandle<OptionHandler> > handlers =
  112. oparser->findByNameSubstring(keyword);
  113. if(!handlers.empty()) {
  114. out->printf(_("Printing options whose name includes '%s'."),
  115. keyword.c_str());
  116. out->printf("\n");
  117. out->printf(_("Options:"));
  118. out->printf("\n");
  119. for(std::vector<SharedHandle<OptionHandler> >::const_iterator i =
  120. handlers.begin(), eoi = handlers.end(); i != eoi; ++i) {
  121. write(out, *(*i));
  122. out->printf("\n");
  123. }
  124. } else {
  125. out->printf(_("No option matching with '%s'."),
  126. keyword.c_str());
  127. out->printf("\n");
  128. write(out, *oparser->find(PREF_HELP));
  129. }
  130. }
  131. if(keyword == strHelpTag(TAG_BASIC)) {
  132. out->printf("URI, MAGNET, TORRENT_FILE, METALINK_FILE:\n");
  133. out->printf(_(" You can specify multiple HTTP(S)/FTP URIs. Unless you specify -Z option, all\n"
  134. " URIs must point to the same file or downloading will fail."));
  135. out->printf("\n");
  136. out->printf(_(" You can also specify arbitrary number of BitTorrent Magnet URIs, torrent/\n"
  137. " metalink files stored in a local drive. Please note that they are always\n"
  138. " treated as a separate download."));
  139. out->printf("\n\n");
  140. out->printf(_(" You can specify both torrent file with -T option and URIs. By doing this,\n"
  141. " download a file from both torrent swarm and HTTP/FTP server at the same time,\n"
  142. " while the data from HTTP/FTP are uploaded to the torrent swarm. For single file\n"
  143. " torrents, URI can be a complete URI pointing to the resource or if URI ends\n"
  144. " with '/', 'name' in torrent file is added. For multi-file torrents, 'name' and\n"
  145. " 'path' in torrent are added to form a URI for each file."));
  146. out->printf("\n\n");
  147. out->printf(_(" Make sure that URI is quoted with single(\') or double(\") quotation if it\n"
  148. " contains \"&\" or any characters that have special meaning in shell."));
  149. out->printf("\n\n");
  150. out->printf(_("About the number of connections\n"
  151. " Since 1.10.0 release, aria2 uses 1 connection per host by default and has 20MiB\n"
  152. " segment size restriction. So whatever value you specify using -s option, it\n"
  153. " uses 1 connection per host. To make it behave like 1.9.x, use\n"
  154. " --max-connection-per-server=4 --min-split-size=1M.\n"
  155. "\n"));
  156. }
  157. out->printf(_("Refer to man page for more information."));
  158. out->printf("\n");
  159. }
  160. } // namespace aria2