I am trying to write a python program that will provide some github features in cli like creating issues, creating repos, creating PRs, etc.
I came up with something like
github create issue --title <title> --description <description> --user <user> --repo <repo>
I used argparse for this purpose
import argparse
parser = argparse.parser()
parser.add_argument('create',
options=['issue', 'repo', 'pull')
action='store')
parser.add_argument('--title', action="store", type=str)
parser.add_argument('--description', action="store", type=str)
parser.add_argument('--user', action="store")
parser.add_argument('--repo')
parser.parse_args('create issue --title title --description desc --user user --repo repo')
I used the options --title
and --descriptions
to get the information in keyword form.
While options are meant to be optional, but according to my style of parsing:
- If
create
isissue
then--title
,--description
,--user
,--repo
are required.
What will be the right approach of parsing the command github create issue --title title --description desc --user user --repo repo
?