version_usage.cc 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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 "SharedHandle.h"
  37. #include "a2io.h"
  38. #include "FeatureConfig.h"
  39. #ifdef ENABLE_MESSAGE_DIGEST
  40. # include "messageDigest.h"
  41. #endif // ENABLE_MESSAGE_DIGEST
  42. #include "help_tags.h"
  43. #include "prefs.h"
  44. #include "StringFormat.h"
  45. #include "OptionParser.h"
  46. #include "OptionHandler.h"
  47. #include <iostream>
  48. #include <iterator>
  49. #include <algorithm>
  50. namespace aria2 {
  51. void showVersion() {
  52. std::cout << PACKAGE << _(" version ") << PACKAGE_VERSION << "\n"
  53. << "Copyright (C) 2006, 2008 Tatsuhiro Tsujikawa" << "\n"
  54. << "\n"
  55. <<
  56. "This program is distributed in the hope that it will be useful,\n"
  57. "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
  58. "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
  59. "GNU General Public License for more details.\n"
  60. << "\n"
  61. << "** Configuration **" << "\n"
  62. << "Enabled Features: "
  63. << FeatureConfig::getInstance()->featureSummary() << "\n"
  64. #ifdef ENABLE_MESSAGE_DIGEST
  65. << "Hash Algorithms: "
  66. << MessageDigestContext::getSupportedAlgoString() << "\n"
  67. #endif // ENABLE_MESSAGE_DIGEST
  68. << "\n"
  69. << StringFormat(_("Report bugs to %s"), "<tujikawa at users dot sourceforge dot net>")
  70. << std::endl;
  71. }
  72. void showUsage(const std::string& keyword, const OptionParser& oparser) {
  73. std::cout << StringFormat(_("Usage: %s [OPTIONS] [URL | TORRENT_FILE |"
  74. " METALINK_FILE]..."), PACKAGE_NAME) << "\n"
  75. << "\n";
  76. std::deque<SharedHandle<OptionHandler> > handlers =
  77. keyword == V_ALL ? oparser.findAll():oparser.findByTag(keyword);
  78. if(handlers.empty()) {
  79. std::deque<SharedHandle<OptionHandler> > handlers =
  80. oparser.findByNameSubstring(keyword);
  81. if(!handlers.empty()) {
  82. std::cout << StringFormat(_("Printing options whose name includes"
  83. " '%s'."), keyword.c_str())
  84. << "\n"
  85. << _("Options:") << "\n";
  86. std::copy(handlers.begin(), handlers.end(),
  87. std::ostream_iterator<SharedHandle<OptionHandler> >
  88. (std::cout, "\n\n"));
  89. } else {
  90. std::cout << StringFormat(_("No help category or option name matching"
  91. " with '%s'."), keyword.c_str())
  92. << "\n" << oparser.findByName("help") << "\n";
  93. }
  94. } else {
  95. if(keyword == V_ALL) {
  96. std::cout << _("Printing all options.");
  97. } else {
  98. std::cout << StringFormat(_("Printing options tagged with '%s'."),
  99. keyword.c_str());
  100. std::cout << "\n";
  101. SharedHandle<OptionHandler> help = oparser.findByName("help");
  102. std::cout << StringFormat(_("See -h option to know other command-line"
  103. " options(%s)."),
  104. help->createPossibleValuesString().c_str());
  105. }
  106. std::cout << "\n"
  107. << _("Options:") << "\n";
  108. std::copy(handlers.begin(), handlers.end(),
  109. std::ostream_iterator<SharedHandle<OptionHandler> >
  110. (std::cout, "\n\n"));
  111. }
  112. if(keyword == TAG_BASIC) {
  113. std::cout << "\n"
  114. << "URL, TORRENT_FILE, METALINK_FILE:" << "\n"
  115. << _(" You can specify multiple URLs. Unless you specify -Z option, all URLs must\n"
  116. " point to the same file or downloading will fail.") << "\n"
  117. << _(" You can also specify arbitrary number of torrent files and metalink files\n"
  118. " stored in a local drive. Please note that they are always treated as a\n"
  119. " separate download.") << "\n"
  120. << "\n"
  121. << _(" You can specify both torrent file with -T option and URLs. By doing this,\n"
  122. " download a file from both torrent swarm and http/ftp server at the same time,\n"
  123. " while the data from http/ftp are uploaded to the torrent swarm. Note that\n"
  124. " only single file torrent can be integrated with http/ftp.") << "\n"
  125. << "\n"
  126. << _(" Make sure that URL is quoted with single(\') or double(\") quotation if it\n"
  127. " contains \"&\" or any characters that have special meaning in shell.") << "\n";
  128. }
  129. std::cout << "\n"
  130. << _("Refer to man page for more information.") << std::endl;
  131. }
  132. } // namespace aria2