diff options
author | Lars Wirzenius <liw@liw.fi> | 2013-02-08 09:48:45 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2013-02-08 09:48:45 +0000 |
commit | aa94f7f0f5ce0b47e5215216d32fa530b43512f8 (patch) | |
tree | 8d68a9dadf418860cf733bb940f65aea4d31de66 | |
parent | 3c8f442f2a7c7d0f09b9071e68d8420a655dc7b3 (diff) | |
download | obnam-aa94f7f0f5ce0b47e5215216d32fa530b43512f8.tar.gz |
Change the ls subcommand to take list of files
Baseo on patch by Damien Couroussé, but with changes
to make it apply to the current version of Obnam, and
to make the test suite pass.
-rw-r--r-- | obnamlib/plugins/restore_plugin.py | 11 | ||||
-rw-r--r-- | obnamlib/plugins/show_plugin.py | 11 | ||||
-rw-r--r-- | obnamlib/plugins/verify_plugin.py | 5 |
3 files changed, 20 insertions, 7 deletions
diff --git a/obnamlib/plugins/restore_plugin.py b/obnamlib/plugins/restore_plugin.py index 29bef635..e5f4c430 100644 --- a/obnamlib/plugins/restore_plugin.py +++ b/obnamlib/plugins/restore_plugin.py @@ -65,9 +65,9 @@ class RestorePlugin(obnamlib.ObnamPlugin): self.app.add_subcommand('restore', self.restore, arg_synopsis='[DIRECTORY]...') self.app.settings.string(['to'], 'where to restore') - self.app.settings.string(['generation'], + self.app.settings.string_list(['generation'], 'which generation to restore', - default='latest') + default=['latest']) @property def write_ok(self): @@ -118,7 +118,12 @@ class RestorePlugin(obnamlib.ObnamPlugin): self.errors = False - gen = self.repo.genspec(self.app.settings['generation']) + generations = self.app.settings['generation'] + if len(generations) != 1: + raise obnamlib.Error( + 'The restore command wants exactly one generation option') + + gen = self.repo.genspec(generations[0]) self.configure_ttystatus() self.app.ts['total'] = self.repo.client.get_generation_file_count(gen) diff --git a/obnamlib/plugins/show_plugin.py b/obnamlib/plugins/show_plugin.py index 60bb5bc1..f13480f2 100644 --- a/obnamlib/plugins/show_plugin.py +++ b/obnamlib/plugins/show_plugin.py @@ -39,7 +39,7 @@ class ShowPlugin(obnamlib.ObnamPlugin): self.app.add_subcommand('clients', self.clients) self.app.add_subcommand('generations', self.generations) self.app.add_subcommand('genids', self.genids) - self.app.add_subcommand('ls', self.ls, arg_synopsis='[GENERATION]...') + self.app.add_subcommand('ls', self.ls, arg_synopsis='[FILE]...') self.app.add_subcommand('diff', self.diff, arg_synopsis='[GENERATION1] GENERATION2') self.app.add_subcommand('nagios-last-backup-age', @@ -134,14 +134,19 @@ class ShowPlugin(obnamlib.ObnamPlugin): def ls(self, args): '''List contents of a generation.''' self.open_repository() - for gen in args or [self.app.settings['generation']] or ["latest"]: + + if len(args) is 0: + args = ['/'] + + for gen in self.app.settings['generation']: gen = self.repo.genspec(gen) started, ended = self.repo.client.get_generation_times(gen) started = self.format_time(started) ended = self.format_time(ended) self.app.output.write( 'Generation %s (%s - %s)\n' % (gen, started, ended)) - self.show_objects(gen, '/') + for ls_file in args: + self.show_objects(gen, ls_file) self.repo.fs.close() def format_time(self, timestamp): diff --git a/obnamlib/plugins/verify_plugin.py b/obnamlib/plugins/verify_plugin.py index 170625fc..cdd055c7 100644 --- a/obnamlib/plugins/verify_plugin.py +++ b/obnamlib/plugins/verify_plugin.py @@ -49,6 +49,9 @@ class VerifyPlugin(obnamlib.ObnamPlugin): self.app.settings.require('repository') self.app.settings.require('client-name') self.app.settings.require('generation') + if len(self.app.settings['generation']) != 1: + raise obnamlib.Error( + 'verify must be given exactly one generation') logging.debug('verifying generation %s' % self.app.settings['generation']) @@ -71,7 +74,7 @@ class VerifyPlugin(obnamlib.ObnamPlugin): self.fs.reinit(root_url) self.failed = False - gen = self.repo.genspec(self.app.settings['generation']) + gen = self.repo.genspec(self.app.settings['generation'][0]) self.app.ts['done'] = 0 self.app.ts['total'] = 0 |