Added --show-console-readout option.

This option toggles appearance of console readout.
pull/1/head
Tatsuhiro Tsujikawa 2011-03-27 19:16:54 +09:00
parent 3d87e4e43a
commit 6e3f512c61
7 changed files with 32 additions and 4 deletions

View File

@ -229,7 +229,8 @@ void printProgressSummary
} // namespace
ConsoleStatCalc::ConsoleStatCalc(time_t summaryInterval, bool humanReadable):
summaryInterval_(summaryInterval)
summaryInterval_(summaryInterval),
readoutVisibility_(true)
{
if(humanReadable) {
sizeFormatter_.reset(new AbbrevSizeFormatter());
@ -276,7 +277,11 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e)
sizeFormatter);
std::cout << "\n";
}
}
if(!readoutVisibility_) {
return;
}
if(e->getRequestGroupMan()->countRequestGroup() > 0) {
SharedHandle<RequestGroup> firstRequestGroup =
e->getRequestGroupMan()->getRequestGroup(0);

View File

@ -62,12 +62,18 @@ private:
time_t summaryInterval_;
SharedHandle<SizeFormatter> sizeFormatter_;
bool readoutVisibility_;
public:
ConsoleStatCalc(time_t summaryInterval, bool humanReadable = true);
virtual ~ConsoleStatCalc() {}
virtual void calculateStat(const DownloadEngine* e);
void setReadoutVisibility(bool visibility)
{
readoutVisibility_ = visibility;
}
};
typedef SharedHandle<ConsoleStatCalc> ConsoleStatCalcHandle;

View File

@ -561,6 +561,14 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
op->hide();
handlers.push_back(op);
}
{
SharedHandle<OptionHandler> op(new BooleanOptionHandler
(PREF_SHOW_CONSOLE_READOUT,
TEXT_SHOW_CONSOLE_READOUT,
A2_V_TRUE));
op->addTag(TAG_ADVANCED);
handlers.push_back(op);
}
{
SharedHandle<OptionHandler> op(new NumberOptionHandler
(PREF_STOP,

View File

@ -94,8 +94,11 @@ SharedHandle<StatCalc> getStatCalc(const SharedHandle<Option>& op)
if(op->getAsBool(PREF_QUIET)) {
statCalc.reset(new NullStatCalc());
} else {
statCalc.reset(new ConsoleStatCalc(op->getAsInt(PREF_SUMMARY_INTERVAL),
op->getAsBool(PREF_HUMAN_READABLE)));
SharedHandle<ConsoleStatCalc> impl
(new ConsoleStatCalc(op->getAsInt(PREF_SUMMARY_INTERVAL),
op->getAsBool(PREF_HUMAN_READABLE)));
impl->setReadoutVisibility(op->getAsBool(PREF_SHOW_CONSOLE_READOUT));
statCalc = impl;
}
return statCalc;
}

View File

@ -218,6 +218,8 @@ const std::string PREF_MAX_DOWNLOAD_RESULT("max-download-result");
const std::string PREF_RETRY_WAIT("retry-wait");
// value: string
const std::string PREF_ASYNC_DNS_SERVER("async-dns-server");
// value: true | false
const std::string PREF_SHOW_CONSOLE_READOUT("show-console-readout");
/**
* FTP related preferences

View File

@ -222,6 +222,8 @@ extern const std::string PREF_MAX_DOWNLOAD_RESULT;
extern const std::string PREF_RETRY_WAIT;
// value: string
extern const std::string PREF_ASYNC_DNS_SERVER;
// value: true | false
extern const std::string PREF_SHOW_CONSOLE_READOUT;
/**
* FTP related preferences

View File

@ -780,3 +780,5 @@
_(" --xml-rpc-listen-all[=true|false] Deprecated. Use --rpc-listen-all instead.")
#define TEXT_XML_RPC_LISTEN_PORT \
_(" --xml-rpc-listen-port=PORT Deprecated. Use --rpc-listen-port instead.")
#define TEXT_SHOW_CONSOLE_READOUT \
_(" --show-console-readout[=true|false] Show console readout.")