summaryrefslogtreecommitdiff
path: root/obnamlib/plugins/show_plugin.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2012-07-07 16:49:25 +0100
committerLars Wirzenius <liw@liw.fi>2012-07-07 16:49:25 +0100
commit9033d8e27ce94548848cf9845462b8aa546a9651 (patch)
treea8977b263dc20999db9a20fc00425b349f42ed50 /obnamlib/plugins/show_plugin.py
parentcfc31ad9757a9fa08b4e712c2ed4744bbce6e0e6 (diff)
downloadobnam-9033d8e27ce94548848cf9845462b8aa546a9651.tar.gz
Merge the show subcommand into diff
Diffstat (limited to 'obnamlib/plugins/show_plugin.py')
-rw-r--r--obnamlib/plugins/show_plugin.py46
1 files changed, 19 insertions, 27 deletions
diff --git a/obnamlib/plugins/show_plugin.py b/obnamlib/plugins/show_plugin.py
index dc955cf2..a3820b22 100644
--- a/obnamlib/plugins/show_plugin.py
+++ b/obnamlib/plugins/show_plugin.py
@@ -41,8 +41,7 @@ class ShowPlugin(obnamlib.ObnamPlugin):
self.app.add_subcommand('genids', self.genids)
self.app.add_subcommand('ls', self.ls, arg_synopsis='[GENERATION]...')
self.app.add_subcommand('diff', self.diff,
- arg_synopsis='[GENERATION1] [GENERATION2]')
- self.app.add_subcommand('show', self.show, arg_synopsis='[GENERATION]')
+ arg_synopsis='[GENERATION1] GENERATION2')
self.app.add_subcommand('nagios-last-backup-age',
self.nagios_last_backup_age)
@@ -238,34 +237,27 @@ class ShowPlugin(obnamlib.ObnamPlugin):
def diff(self, args):
'''Show difference between two generations.'''
- self.open_repository()
- if len(args) < 2:
- raise obnamlib.Error('Need two generations')
- gen1 = self.repo.genspec(args[0])
- gen2 = self.repo.genspec(args[1])
- self.show_diff(gen1, gen2, '/')
- self.repo.fs.close()
+
+ if len(args) not in (1, 2):
+ raise obnamlib.Error('Need one or two generations')
- def show(self, args):
- '''Show file details of a generation.
- obnam show $generation
- is exactly the same as
- obnam show $prevGeneration $generation
- where $prevGeneration is the generation one before $generation
- '''
- if len(args) < 1:
- raise obnamlib.Error('Need a generation')
self.open_repository()
- gen2 = self.repo.genspec(args[0])
- # Now we have the dst/second generation for show_diff. Use
- # genids/list_generations to find the previous generation
- genids = self.repo.list_generations()
- index = genids.index(gen2)
- if index == 0:
- raise obnamlib.Error(
- 'Can\'t show first generation. Use \'ls\' instead')
- gen1 = genids[index - 1]
+ if len(args) == 1:
+ gen2 = self.repo.genspec(args[0])
+ # Now we have the dst/second generation for show_diff. Use
+ # genids/list_generations to find the previous generation
+ genids = self.repo.list_generations()
+ index = genids.index(gen2)
+ if index == 0:
+ raise obnamlib.Error(
+ 'Can\'t show first generation. Use \'ls\' instead')
+ gen1 = genids[index - 1]
+ else:
+ gen1 = self.repo.genspec(args[0])
+ gen2 = self.repo.genspec(args[1])
+
self.show_diff(gen1, gen2, '/')
+ self.repo.fs.close()
def fields(self, gen, full):
metadata = self.repo.get_metadata(gen, full)