def makeParser(): '''Creates and returns argument parser (argparse module).''' parser = argparse.ArgumentParser( description='Deletes specified post.', parents = [args.baseParser(skipfailignore = True, format = False)], ) parser.add_argument('--id', dest = 'id', action = 'store', default = u'-', required = False, help = 'Post ID. If set to "-" (default), list of the post IDs will be read from stdin.' ) return parser
def makeParser(): '''Creates and returns argument parser (argparse module).''' parser = argparse.ArgumentParser( description='Changes post according to specified rules.', parents = [args.baseParser(skipfailignore = True, format = True)], ) parser.add_argument('--id', dest = 'id', action = 'store', default = '-', required = False, help = 'Post ID. If set to "-" (default), list of the post IDs will be read from stdin.' ) group = parser.add_argument_group(title='Editing rules', description='FIND is a regular expression to run on the post. REPLACE is a template string to replace any matches with. For additional information check out http://docs.python.org/library/re.html#re.sub . Several expressions will be applied at the same order they have been specified.') group.add_argument('--body', dest = 'body', action = 'append', nargs = 2, default = [], required = False, metavar = ("FIND","REPLACE"), help = 'Post body (quote text, link description, answer).', ) group.add_argument('--title', dest = 'title', action = 'append', nargs = 2, default = [], required = False, metavar = ("FIND","REPLACE"), help = 'Post title (quote source, photo/audio/video caption, link title, question).' ) group.add_argument('--plain', dest = 'useregexp', action = 'store_const', default = True, const = False, required = False, help = 'Perform simple find-replace instead of regular expression matching.' ) parser.add_argument('--editonly', dest = 'editonly', action = 'store_const', const = True, default = False, required = False, help = '"--editonly" will make the program print the post data to stdout only if any actual changes have been made.' ) return parser
def makeParser(): '''Creates and returns argument parser (argparse module).''' parser = argparse.ArgumentParser( description='Changes post tags according to specified rules.', usage='\t%(prog)s -b BLOG [options] [-- action [action [...]]]\n\t%(prog)s --help', parents = [args.baseParser(skipfailignore = True, format = True)], ) parser.add_argument('--id', dest = 'id', action = 'store', default = '-', required = False, help = 'Post ID. If set to "-" (default), list of the post IDs will be read from stdin.' ) parser.add_argument('actions', action = 'store', nargs = '*', type = args.taglist('+-!'), default = [], metavar = 'action', help = 'Actions to perform. Syntax: +tag_to_add, -tag_to_remove, !tag_to_toggle.' ) return parser
def makeParser(): '''Creates and returns argument parser (argparse module).''' parser = argparse.ArgumentParser( description='Retrieves posts list from specified blog. OAuth is not required.', parents = [args.baseParser(skipfailignore = False, format = True)], #add_help=False, ) group = parser.add_argument_group(title='Basic filters') group.add_argument('--id', dest = 'id', action = 'store', default = None, required = False, help = 'Post ID. If specified, then results will be limited by that post.' ) group.add_argument('--type', dest = 'type', action = 'store', type = unicode.lower, choices = (u'all', u'text', u'photo', u'quote', u'link', u'chat', u'audio', u'video', u'answer'), default = u'all', required = False, metavar = 'TYPE', help = 'Determines type of the retrieved posts. Possible values are %(choices)s. Defaults to "%(default)s".', ) group.add_argument('--tag', dest = 'tags', action = 'append', type = args.taglist('+-'), default = [], required = False, metavar = 'TAG', help = 'Tag restrictions. Syntax: --tag=+required_tag --tag=-prohibited_tag', ) group = parser.add_argument_group(title='Regexp filters') group.add_argument('--body', dest = 'body', action = 'store', default = u'', type = args.match_regexp, required = False, help = 'Regular expression to match the post body (quote text, link description, answer) against.' ) group.add_argument('--title', dest = 'title', action = 'store', type = args.match_regexp, default = u'', required = False, help = 'Regular expression to match the post title (quote source, photo/audio/video caption, link title, question) against.' ) group.add_argument('--source', dest = 'source', action = 'store', type = args.match_regexp, default = u'', required = False, help = 'Regular expression to match the post source or question source URL against.' ) group.add_argument('--plain', dest = 'plaintext', action = 'store_const', const = True, default = False, required = False, help = 'Work with plain text version of the post, not with HTML.' ) group = parser.add_argument_group(title='Date filters') group.add_argument('--before', dest = 'before', action = 'store', type = args.timestamp, default = None, required = False, help = 'Retrieve only posts with timestamp earlier than specified. Format is 1999-12-31T23:59:59.' ) group.add_argument('--after', dest = 'after', action = 'store', type = args.timestamp, default = None, required = False, help = 'Retrieve only posts with timestamp later than specified. Format is 1999-12-31T23:59:59.' ) group = parser.add_argument_group(title='Query limits') group.add_argument('-N', '--count', '--limit', dest = 'count', action = 'store', type = int, default = None, required = False, help = 'How many posts should be retrieved.', ) group.add_argument('-S', '--offset', '--start', dest = 'offset', action = 'store', type = int, default = 0, required = False, help = 'How many posts should be skipped.', ) group.add_argument('--slice', dest = 'slice', action = 'store', type = int, default = None, required = False, help = 'Receive data in portions no bigger than SLICE posts.' ) return parser