From 8de4753693f75454d4d3775b087d35c3e18af4ae Mon Sep 17 00:00:00 2001 From: Jan Kupec Date: Wed, 1 Nov 2006 16:30:13 +0000 Subject: [PATCH] -y, --no-confirm option implemented for install, remove, and update command --- doc/zypper.8 | 19 ++++++++++++++----- src/zmart-misc.cc | 6 +++--- src/zmart-misc.h | 2 +- src/zypper.cc | 18 ++++++++++++------ 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/doc/zypper.8 b/doc/zypper.8 index d739b2f..81c60eb 100644 --- a/doc/zypper.8 +++ b/doc/zypper.8 @@ -44,11 +44,14 @@ Displays full info for the specified packages. .B install (in) [name] ... Install resolvables. .TP -\fI\-c, -\-catalog\fR -Only from this catalog (FIXME) +\fI\-c, \-\-catalog\fR +Only from this catalog (FIXME not implemented yet) .TP -\fI\-t, -\-type\fR [resolvable] +\fI\-t, \-\-type\fR [resolvable] Type of resolvable (default: package) +.TP +.I \-y, \-\-no-confirm +Don't require user confirmation. .TP .B list-updates (lu) @@ -63,13 +66,19 @@ Remove resolvables. .TP \fI\-t, -\-type\fR [resolvable] Type of resolvable (default: package) +.TP +.I \-y, \-\-no-confirm +Don't require user confirmation. .TP .B update (up) Update resolvables. .TP -\fI\-t, --type\fR +\fI\-t, -\-type\fR [resolvable] Type of resolvable (default: patch) +.TP +.I \-y, \-\-no-confirm +Don't require user confirmation. .TP \fBsearch\fR (\fBse\fR) [\fIoptions\fR] [\fBquerystring\fR] ... @@ -99,7 +108,7 @@ Show only resolvables that are already installed. .I \-u, \-\-uninstalled\-only Show only resolvables that are not currently installed. .TP -.I \-t, \-\-type +\fI\-t, -\-type\fR [resolvable] Search only for resolvables of specified type. .TP .I \-c, \-\-catalog diff --git a/src/zmart-misc.cc b/src/zmart-misc.cc index 9aef298..98638f5 100644 --- a/src/zmart-misc.cc +++ b/src/zmart-misc.cc @@ -514,7 +514,7 @@ void mark_updates( const ResObject::Kind &kind ) } } -void solve_and_commit () { +void solve_and_commit (bool non_interactive) { cerr_v << "resolving" << endl; resolve(); @@ -522,8 +522,8 @@ void solve_and_commit () { if (show_summary()) { - cerr << "Continue? [y/n] "; - if (readBoolAnswer()) { + cerr << "Continue? [y/n] " << (non_interactive ? "y\n" : ""); + if (non_interactive || readBoolAnswer()) { cerr_v << "committing" << endl; ZYppCommitResult result = God->commit( ZYppCommitPolicy() ); cerr_v << result << std::endl; diff --git a/src/zmart-misc.h b/src/zmart-misc.h index 2b0545e..ae8dcaa 100644 --- a/src/zmart-misc.h +++ b/src/zmart-misc.h @@ -38,7 +38,7 @@ void patch_check(); void list_updates( const zypp::ResObject::Kind &kind ); void mark_updates( const zypp::ResObject::Kind &kind ); void usage(int argc, char **argv); -void solve_and_commit (); +void solve_and_commit (bool non_interactive = false); // copied from yast2-pkg-bindings:PkgModuleFunctions::DoProvideNameKind struct ProvideProcess diff --git a/src/zypper.cc b/src/zypper.cc index de5d97f..2357cbc 100644 --- a/src/zypper.cc +++ b/src/zypper.cc @@ -195,24 +195,28 @@ int one_command(const string& command, int argc, char **argv) if (command == "install" || command == "in") { static struct option install_options[] = { - {"catalog", required_argument, 0, 'c'}, - {"type", required_argument, 0, 't'}, + {"catalog", required_argument, 0, 'c'}, + {"type", required_argument, 0, 't'}, + {"no-confirm", no_argument, 0, 'y'}, {0, 0, 0, 0} }; specific_options = install_options; specific_help = " Command options:\n" "\t--catalog,-c\t\tOnly from this catalog (FIXME)\n" "\t--type,-t\t\tType of resolvable (default: package)\n" + "\t--no-confirm,-y\tDon't require user confirmation\n" ; } else if (command == "remove" || command == "rm") { static struct option remove_options[] = { - {"type", required_argument, 0, 't'}, + {"type", required_argument, 0, 't'}, + {"no-confirm", no_argument, 0, 'y'}, {0, 0, 0, 0} }; specific_options = remove_options; specific_help = " Command options:\n" "\t--type,-t\t\tType of resolvable (default: package)\n" + "\t--no-confirm,-y\tDon't require user confirmation\n" ; } else if (command == "service-add" || command == "sa") { @@ -259,12 +263,14 @@ int one_command(const string& command, int argc, char **argv) } else if (command == "update" || command == "up") { static struct option remove_options[] = { - {"type", required_argument, 0, 't'}, + {"type", required_argument, 0, 't'}, + {"no-confirm", no_argument, 0, 'y'}, {0, 0, 0, 0} }; specific_options = remove_options; specific_help = " Command options:\n" "\t--type,-t\t\tType of resolvable (default: patch)\n" + "\t--no-confirm,-y\tDon't require user confirmation\n" ; } else if (command == "search" || command == "se") { @@ -579,7 +585,7 @@ int one_command(const string& command, int argc, char **argv) mark_for_uninstall(kind, *it); } - solve_and_commit (); + solve_and_commit (copts.count("no-confirm")); } return 0; } @@ -734,7 +740,7 @@ int one_command(const string& command, int argc, char **argv) establish (); mark_updates (kind); - solve_and_commit (); + solve_and_commit (copts.count("no-confirm")); return 0; } -- 2.7.4