def handle(self, args): """ Handle command. """ item = args.item index = -1 items = len(self.archive.items) if item.isdigit(): index = int( item ) if index < 0 or index >= items: say('No such {0}. There are {1} {0}s.'.format(self.mcmd, items)) return else: index = self.archive.find( 1, item ) if index == -1: say('No such '+self.mcmd+'.') say('Use `./dlab item list` to see archive {0}s.'.format(self.mcmd)) return if index == items: say('Item {0} is already at the bottom.'.format(item)) return si = index + 1 proj = self.archive.items[index] self.archive.items[index] = self.archive.items[si] self.archive.items[si] = proj self.archive.save() self.archive.load() say('Shifted item {0} down to position {1}.'.format(item, si))
def handle(self, args): """ Handle command. """ say('Current {0}s:'.format(self.mcmd)) for index, item in enumerate(self.archive.items): say( ' {0} - {1}'.format( index, item[1] ) )
def handle(self, args): """ Handle command. """ item = args.item index = -1 items = len(self.archive.items) if item.isdigit(): index = int( item ) if index < 0 or index >= items: say('No such {0}. There are {1} {0}s.'.format(self.mcmd, items)) return else: index = self.archive.find( 1, item ) if index == -1: say('No such '+self.mcmd+'.') say('Use `./dlab {0} list` to see archived {0}s.'.format(self.mcmd)) return item = self.archive.items[index] self.archive.items[index] = [ args.url or item[0], args.title or item[1], args.tags or item[2], (args.description or item[3]).replace('\!', '!')] self.archive.save() self.archive.load() say('Saved changes to {0} {1}.'.format(self.mcmd, index))
def handle(self, args): """ Handle command. """ item = args.item removed = False if item.isdigit(): removed = self.archive.remove( int( item ) ) else: removed = self.archive.removeMatched( 1, item ) if removed: say('Removed {0} {1} from the archive.'.format(self.mcmd, item)) else: say('No such '+self.mcmd)
def handle(self, args): """ Handle command. """ self.archive.add(args.index, [args.url, args.title, args.tags, args.description.replace('\!', '!')]) say('Added {0} "{1}" to the list.'.format(self.mcmd, args.title))
def handle(self, args): """ Handle command. """ item = args.item index = -1 items = len(self.archive.items) if item.isdigit(): index = int( item ) if index < 0 or index >= items: say('No such {0}. There are {1} {0}s.'.format(self.mcmd, items)) return else: index = self.archive.find( 1, item ) if index == -1: say('No such '+self.mcmd+'.') say('Use `./dlab {0} list` to see archived {0}s.'.format(self.mcmd)) return item = self.archive.items[index] say(self.mcmd + ' ' + str(index)) say('title: ' + item[1]) say('url: ' + item[0]) say('description: ' + item[3]) say('tags: ' + item[2])