def create_parser(): # createPARSER prog_name = "parsetest.py" version = "0.1.0" desc = "unittest" parser = miniparser.parser(version, desc) parser.prog_name = "sample" @parser.option("-m","--message","msg", description="print message") def print_msg(msg,count): print msg*int(count) @parser.option("-c","--calc","calc", description="caluate") def calc(num1, num2): print int(num1)+int(num2) return parser
#!/usr/bin/env python #coding: utf-8 import os import sys import commands import miniparser from util import core from util import adjust from util.git import * from util.color import * from StringIO import StringIO parser = miniparser.parser( version="1.0.1", description="The commithash support operating git commit hash") @parser.default(description="You can show latest commit hash.") def latest(): commits = adjust.get_commits() print commits[0].commithash @parser.option( "ls", description="You can show all commit hash " \ "with number, date, author, comment") def show_all(): commits = adjust.get_commits() pager = get_pager() io = StringIO()
#!/usr/bin/env python # coding: utf-8 import os import sys import miniparser from miniparser import kill from icalendar import Calendar from dateutil.relativedelta import relativedelta from StringIO import StringIO parser = miniparser.parser() date_format = "%Y/%m/%d" time_format = "%H:%M:%S" @parser.option("-s", "--show-event", description="Show event list and time. Please set .ics file to arg.") def show_event(ics_file): check_exist_file(ics_file) ical = Calendar.from_ical(open(ics_file, "r").read()) for event in get_events(ical): # about time start = event.get("dtstart").dt end = event.get("dtend").dt print start.strftime(date_format), ":", print start.strftime(time_format), "~", end.strftime(time_format), ":", # about time diff delta = relativedelta(end, start)
import miniparser from util import core from util import adjust from util import objects from util.git import * from util.color import * from util.objects import Todo from subprocess import Popen, PIPE from StringIO import StringIO from datetime import datetime from sys import exit as kill parser = miniparser.parser( version="0.1.0b", description="You can manage to" \ "What you want to do on your git repository") CACHE_FILE = os.path.join(git_directory(), "gitodo") CACHE_FILE_PATH = os.path.join(os.getcwd(), CACHE_FILE) @parser.default(description="Show all ToDos.") def default(): if os.access(CACHE_FILE_PATH, os.F_OK) != True: print "The repository does not todo initialized yet." print "Please do 'git todo init'" kill(1) # get todo container todo_container = core.load_state(open(CACHE_FILE_PATH,"r")) if len(todo_container) == 0:
#!/usr/bin/env python #coding: utf-8 import miniparser parser = miniparser.parser(description="miniparser test script",version="1.0") @parser.default(description="show license.") def show_license(): print "License : MIT" @parser.option("-m","msg","--message","--msg", description="this is help msg.", argument_types={"msg":str,"count":int}) def printer(msg, count): print msg*count @parser.option("-p","plus","--plus", description="plus number.", argument_types={"num1":int,"num2":int}) def calc(num1, num2): print num1+num2 if __name__ == "__main__": parser.parse()