Commit 2ae659e9 authored by Lukas Appelhans's avatar Lukas Appelhans

NoConfirm and OnlyNeeded implemented

parent 726d33ac
......@@ -48,6 +48,7 @@ enum OptionName
DatabaseOnly,
RemoveConfig,
Recursive,
NoConfirm,
Debug,
RootDir,
CacheDir,
......
......@@ -36,6 +36,7 @@ void initOptions(CommandLineParser *parser, bool isAkabei)
parser->addOption(APM::Force, "f", "force", ki18n("Force installation. Overwrite file conflicts"));
parser->addOption(APM::DownloadOnly, "w", "downloadonly", ki18n("Only downloads packages without performing any operation"));
parser->addOption(APM::OnlyNeeded, "", "needed", ki18n("Up-to-date packages are not reinstalled"));
parser->addOption(APM::NoConfirm, "", "noconfirm", ki18n("Answer all questions with the recommended answer"));
parser->addOption(APM::Ignore, "", "ignore", ki18n("Ignore one or more packages (separated by comma)"), ki18n("packages"));
parser->addOption(APM::IgnoreGroup, "", "ignoregroup", ki18n("Ignores one or more groups (separated by comma)"), ki18n("groups"));
parser->addOption(APM::DatabaseOnly, "k", "dbonly", ki18n("Only remove database entries"));
......@@ -107,6 +108,7 @@ void initAkabeiOperations(CommandLineParser *parser)
install.addConnectionWithOption(APM::DownloadOnly);
install.addConnectionWithOption(APM::Force);
install.addConnectionWithOption(APM::OnlyNeeded);
install.addConnectionWithOption(APM::NoConfirm);
AkabeiOperation repo(APM::SyncOperationType, APM::ListRepo, "", "repo", ki18n("List all packages in a repository"), true);
repo.addConnectionWithOption(APM::Ignore);
......@@ -122,6 +124,7 @@ void initAkabeiOperations(CommandLineParser *parser)
remove.addConnectionWithOption(APM::RemoveConfig);
remove.addConnectionWithOption(APM::Recursive);
remove.addConnectionWithOption(APM::SkipDependencyCheck);
remove.addConnectionWithOption(APM::NoConfirm);
AkabeiOperation clean(APM::RemoveOperationType, APM::Unneeded, "", "clean", ki18n("Removes orphan packages"), false);
clean.addConnectionWithOption(APM::Force);
......@@ -138,12 +141,14 @@ void initAkabeiOperations(CommandLineParser *parser)
update.addConnectionWithOption(APM::Ignore);
update.addConnectionWithOption(APM::IgnoreGroup);
update.addConnectionWithOption(APM::Force);
update.addConnectionWithOption(APM::NoConfirm);
AkabeiOperation upgrade(APM::SyncOperationType, APM::UpgradeSystem, "", "upgrade", ki18n("Update databases and system"), false);
upgrade.addConnectionWithOption(APM::DownloadOnly);
upgrade.addConnectionWithOption(APM::Ignore);
upgrade.addConnectionWithOption(APM::IgnoreGroup);
upgrade.addConnectionWithOption(APM::Force);
upgrade.addConnectionWithOption(APM::NoConfirm);
AkabeiOperation newest(APM::SyncOperationType, APM::Newest, "", "newest", ki18n("Upgrade databases and then install packages"), true);
newest.addConnectionWithOption(APM::InstallAsDeps);
......@@ -152,6 +157,7 @@ void initAkabeiOperations(CommandLineParser *parser)
newest.addConnectionWithOption(APM::DownloadOnly);
newest.addConnectionWithOption(APM::Force);
newest.addConnectionWithOption(APM::OnlyNeeded);
newest.addConnectionWithOption(APM::NoConfirm);
AkabeiOperation perform(APM::PerformOperationType, APM::Perform, "", "perform", ki18n("Perform various removals and installations"), true);
perform.addConnectionWithOption(APM::Force);
......@@ -162,12 +168,14 @@ void initAkabeiOperations(CommandLineParser *parser)
perform.addConnectionWithOption(APM::InstallAsExplicit);
perform.addConnectionWithOption(APM::SkipDependencyCheck);
perform.addConnectionWithOption(APM::OnlyNeeded);
perform.addConnectionWithOption(APM::NoConfirm);
AkabeiOperation get(APM::UpgradeOperationType, APM::UpgradeOperation, "", "get", ki18n("Upgrade operation"), true);
get.addConnectionWithOption(APM::Force);
get.addConnectionWithOption(APM::InstallAsDeps);
get.addConnectionWithOption(APM::InstallAsExplicit);
get.addConnectionWithOption(APM::SkipDependencyCheck);
get.addConnectionWithOption(APM::NoConfirm);
parser->addOperation(installed);
parser->addOperation(changelog);
......@@ -249,6 +257,7 @@ void initPakabeiOperations(CommandLineParser *parser)
remove.addConnectionWithOption(APM::RemoveConfig);
remove.addConnectionWithOption(APM::Recursive);
remove.addConnectionWithOption(APM::SkipDependencyCheck);
remove.addConnectionWithOption(APM::NoConfirm);
AkabeiOperation unneeded(APM::RemoveOperationType, APM::Unneeded, "u", "unneeded", ki18n("Remove not needed packages"), false);
unneeded.addConnectionWithOption(APM::Force);
......@@ -264,6 +273,7 @@ void initPakabeiOperations(CommandLineParser *parser)
install.addConnectionWithOption(APM::Force);
install.addConnectionWithOption(APM::DownloadOnly);
install.addConnectionWithOption(APM::OnlyNeeded);
install.addConnectionWithOption(APM::NoConfirm);
AkabeiOperation groups(APM::SyncOperationType, APM::ShowPackagesOfGroup, "g", "groups", ki18n("Shows all packages in a package group"), true);
......@@ -286,12 +296,14 @@ void initPakabeiOperations(CommandLineParser *parser)
sysupgrade.addConnectionWithOption(APM::Ignore);
sysupgrade.addConnectionWithOption(APM::IgnoreGroup);
sysupgrade.addConnectionWithOption(APM::Force);
sysupgrade.addConnectionWithOption(APM::NoConfirm);
AkabeiOperation upgrade(APM::UpgradeOperationType, APM::UpgradeOperation, "U", "", ki18n("Upgrade operation"), true);
upgrade.addConnectionWithOption(APM::Force);
upgrade.addConnectionWithOption(APM::InstallAsDeps);
upgrade.addConnectionWithOption(APM::InstallAsExplicit);
upgrade.addConnectionWithOption(APM::SkipDependencyCheck);
upgrade.addConnectionWithOption(APM::NoConfirm);
AkabeiOperation perform(APM::PerformOperationType, APM::Perform, "P", "", ki18n("Performs a series of installations and removals"), true);
perform.addConnectionWithOption(APM::SkipDependencyCheck);
......@@ -303,6 +315,7 @@ void initPakabeiOperations(CommandLineParser *parser)
perform.addConnectionWithOption(APM::InstallAsExplicit);
perform.addConnectionWithOption(APM::DownloadOnly);
perform.addConnectionWithOption(APM::OnlyNeeded);
perform.addConnectionWithOption(APM::NoConfirm);
parser->addOperation(changelog);
parser->addOperation(log);
......
......@@ -75,6 +75,8 @@ void QueueOperation::start(AkabeiClient::PackageAction action, QList<Akabei::Pac
m_action = action;
foreach (Akabei::Package * pkg, packages) {
if (m_options.contains(APM::OnlyNeeded) && pkg->isInstalled())
continue;
AkabeiClient::Backend::instance()->queue()->addPackage(pkg, action);
}
......@@ -99,6 +101,10 @@ void QueueOperation::transactionCreated(AkabeiClient::Transaction* t)
}
if (!t->questions().isEmpty()) {
foreach (AkabeiClient::TransactionQuestion *q, t->questions()) {
if (m_options.contains(APM::NoConfirm)) {
q->setAnswer(q->suggestedAnswer());
continue;
}
out << q->question() << "[";
if (q->possibleAnswers() & AkabeiClient::TransactionQuestion::Yes) {
if (q->suggestedAnswer() == AkabeiClient::TransactionQuestion::Yes)
......@@ -264,11 +270,15 @@ void QueueOperation::validationFinished(bool valid)
out << i18n("Continue with processing?[Y/n]");
out.flush();
std::string input;
getline(std::cin, input);
if (!input.empty() && input != i18n("y").toStdString()) {
emit finished();
return;
if (!m_options.contains(APM::NoConfirm)) {
std::string input;
getline(std::cin, input);
if (!input.empty() && input != i18n("y").toStdString()) {
emit finished();
return;
}
} else {
out << i18nc("yes", "Y") << endl;
}
m_bar.setColumns(ProgressBar::Status | ProgressBar::Details | ProgressBar::Progress | ProgressBar::Eta);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment