X-Git-Url: https://projects.mako.cc/source/mw/blobdiff_plain/ac7e90d463ab412375247a74083fe8f7385729b5..fc69b26dbca870828cb1e5fe4e580532a39540b7:/src/mw/clicommands.py diff --git a/src/mw/clicommands.py b/src/mw/clicommands.py index 7ead096..9360822 100644 --- a/src/mw/clicommands.py +++ b/src/mw/clicommands.py @@ -48,6 +48,11 @@ class CommandBase(object): def _login(self): user = raw_input('Username: ') passwd = getpass.getpass() + result = self.api.call({'action': 'login', + 'lgname': user, + 'lgpassword': passwd}) + if result['login']['result'] != 'Success': + raise Exception('Login error: %s' % result['login']['result']) def _die_if_no_init(self): if self.metadir.config is None: @@ -72,11 +77,10 @@ class InitCommand(CommandBase): self.metadir.create(self.args[0]) -class FetchCommand(CommandBase): +class PullCommand(CommandBase): def __init__(self): usage = '%prog fetch [options] PAGENAME ...' - CommandBase.__init__(self, 'fetch', 'fetch remote pages', usage) - self.shortcuts.append('ft') + CommandBase.__init__(self, 'pull', 'add remote pages to repo', usage) def _do_command(self): self._die_if_no_init() @@ -97,8 +101,9 @@ class FetchCommand(CommandBase): print '%s: %s: page does not exist, file not created' % \ (self.me, pagename) continue - revid = [x['revid'] for x in response[pageid]['revisions']] - self.metadir.pagedict_add(pagename, int(pageid)) + revids = [x['revid'] for x in response[pageid]['revisions']] + revids.sort() + self.metadir.pagedict_add(pagename, pageid, revids[-1]) self.metadir.pages_add_rv(int(pageid), response[pageid]['revisions'][0]) filename = mw.api.pagename_to_filename(pagename)