From: David Sterba Date: Wed, 24 Sep 2014 22:53:31 +0000 (+0200) Subject: client: Add option to list snapshots from all configs X-Git-Tag: v0.2.5~8^2^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=aaa08158e043b52bed5412a42cb8266cb42c34cf;p=thirdparty%2Fsnapper.git client: Add option to list snapshots from all configs $ snapper list -a will print the same output as 'list' but each table is preceded with config name and subvolume. This is convenient way to see all configured snapshots in the system, compared to listing all configs and then typing each command separately. --- diff --git a/client/snapper.cc b/client/snapper.cc index 4ef5eb3f..9be54576 100644 --- a/client/snapper.cc +++ b/client/snapper.cc @@ -141,6 +141,32 @@ help_list_configs() } +list > +enum_configs(DBus::Connection* conn) +{ + list > configs; + + if (no_dbus) + { + list config_infos = Snapper::getConfigs(); + for (list::const_iterator it = config_infos.begin(); it != config_infos.end(); ++it) + { + configs.push_back(make_pair(it->getConfigName(), it->getSubvolume())); + } + } + else + { + list config_infos = command_list_xconfigs(*conn); + for (list::const_iterator it = config_infos.begin(); it != config_infos.end(); ++it) + { + configs.push_back(make_pair(it->config_name, it->subvolume)); + } + } + + return configs; +} + + void command_list_configs(DBus::Connection* conn, Snapper* snapper) { @@ -382,15 +408,20 @@ help_list() << endl << _(" Options for 'list' command:") << endl << _("\t--type, -t \t\tType of snapshots to list.") << endl + << _("\t--all-configs, -a\t\tList snapshots from all accessible configs.") << endl << endl; } +enum ListMode { LM_ALL, LM_SINGLE, LM_PRE_POST }; + +void list_from_one_config(DBus::Connection* conn, Snapper* snapper, string config_name, ListMode list_mode); void command_list(DBus::Connection* conn, Snapper* snapper) { const struct option options[] = { { "type", required_argument, 0, 't' }, + { "all-configs", no_argument, 0, 'a' }, { 0, 0, 0, 0 } }; @@ -401,7 +432,6 @@ command_list(DBus::Connection* conn, Snapper* snapper) exit(EXIT_FAILURE); } - enum ListMode { LM_ALL, LM_SINGLE, LM_PRE_POST }; ListMode list_mode = LM_ALL; GetOpts::parsed_opts::const_iterator opt; @@ -421,6 +451,29 @@ command_list(DBus::Connection* conn, Snapper* snapper) } } + list > configs; + if ((opt = opts.find("all-configs")) != opts.end()) + { + configs = enum_configs(conn); + } + else + { + configs.push_back(make_pair(config_name, "")); + } + + for (list >::iterator it = configs.begin(); it != configs.end(); ++it) + { + if (it != configs.begin()) + cout << endl; + + if (configs.size() > 1) + cout << "Config: " << it->first << ", subvolume: " << it->second << endl; + list_from_one_config(conn, snapper, it->first, list_mode); + } +} + +void list_from_one_config(DBus::Connection* conn, Snapper* snapper, string config_name, ListMode list_mode) +{ Table table; switch (list_mode) diff --git a/doc/snapper.xml.in b/doc/snapper.xml.in index 45a09168..eefd1d7b 100644 --- a/doc/snapper.xml.in +++ b/doc/snapper.xml.in @@ -310,6 +310,12 @@ all, single and pre-post. + + + + List snapshots from all configs accessible by the user. + + diff --git a/package/snapper.changes b/package/snapper.changes index c30e0bf0..48e2476a 100644 --- a/package/snapper.changes +++ b/package/snapper.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Fri Oct 3 01:05:01 CEST 2014 - dsterba@suse.cz + +- add option --all-configs to snapper client, list snapshots from + all accessible configs + ------------------------------------------------------------------- Mon Sep 29 11:55:37 CEST 2014 - aschnell@suse.de