aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-07-02 13:53:32 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-07-02 13:53:32 +0100
commit63521387a13d7e1ec9428993cae6ebfc94569e02 (patch)
tree0bd5edf1c06829caffe6cf0158220ae510915866
parentc08ca14fbf969516f1addaf148d2ac66daf05534 (diff)
downloadpaludis-63521387a13d7e1ec9428993cae6ebfc94569e02.tar.gz
paludis-63521387a13d7e1ec9428993cae6ebfc94569e02.tar.xz
cave show --one-version
-rw-r--r--src/clients/cave/cmd_show.cc26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/clients/cave/cmd_show.cc b/src/clients/cave/cmd_show.cc
index f3fd874..b66ff60 100644
--- a/src/clients/cave/cmd_show.cc
+++ b/src/clients/cave/cmd_show.cc
@@ -93,6 +93,7 @@ namespace
args::ArgsGroup g_display_options;
args::SwitchArg a_flat;
args::SwitchArg a_raw_names;
+ args::SwitchArg a_one_version;
ShowCommandLine() :
g_object_options(main_options_section(), "Object Options", "Alter how objects are interpreted."),
@@ -115,7 +116,10 @@ namespace
a_flat(&g_display_options, "flat", 'f',
"Do not spread key values over multiple lines", true),
a_raw_names(&g_display_options, "raw-names", 'r',
- "Display raw rather than human readable key names", true)
+ "Display raw rather than human readable key names", true),
+ a_one_version(&g_display_options, "one-version", '1',
+ "Display only a single version of any package, rather than all installed and the "
+ "best installable package", true)
{
add_usage_line("spec ...");
}
@@ -895,11 +899,21 @@ namespace
cout << endl;
}
- for (PackageIDSequence::ConstIterator i(all_installed->begin()), i_end(all_installed->end()) ;
- i != i_end ; ++i)
- do_one_package_id(cmdline, env, *i);
- if (best_installable)
- do_one_package_id(cmdline, env, best_installable);
+ if (cmdline.a_one_version.specified())
+ {
+ if (best_installable)
+ do_one_package_id(cmdline, env, best_installable);
+ else if (! all_installed->empty())
+ do_one_package_id(cmdline, env, *all_installed->rbegin());
+ }
+ else
+ {
+ for (PackageIDSequence::ConstIterator i(all_installed->begin()), i_end(all_installed->end()) ;
+ i != i_end ; ++i)
+ do_one_package_id(cmdline, env, *i);
+ if (best_installable)
+ do_one_package_id(cmdline, env, best_installable);
+ }
cout << endl;
}