work on shell ui with argparse

This commit is contained in:
maste9 2015-01-29 13:54:19 +01:00 committed by Homer S
parent 33160dd3ac
commit c85ac83183
1 changed files with 10 additions and 5 deletions

View File

@ -11,18 +11,23 @@ parser = ArgumentParser(description="Manage your weblog via commandline. Creates
parser.add_argument('-d','--blog-dir', dest="blog_dir", default='~/public_html/blog', help='path to blog directory (default: %(default)s)')
### subroutines of pb
# 'update' command
subparsers = parser.add_subparsers(help="subcommands")
parser_update = subparsers.add_parser('update', help='updates blog to current state')
subparsers = parser.add_subparsers(help="targets of operation")
parser_blog = subparsers.add_parser('blog', help='add or update blog or its sections')
## 'blog' subroutines
subparsers_blog = parser_blog.add_subparsers(help="blog subcommands")
parser_update = subparsers_blog.add_parser('update', help='updates blog to current state')
parser_update.add_argument('subsection', choices=['all','recent','archive','feed'], help='sections of blog you may want to update')
parser_add = subparsers_blog.add_parser("add", help='add an non-existing blog at --blog-dir')
# 'draft' command
parser_draft = subparsers.add_parser('draft', help='create, list, edit or remove drafts')
parser_draft.add_argument('action', choices=['add','list','edit','remove'], help='define what to do with a certain draft')
parser_draft.add_argument('nameorid', choices=['name','id']
parser_draft.add_argument('nameorid', choices=['name','id'], help='define an alphanumeric name for draft or the database id specified by [list]')
# 'article' command
parser_article = subparsers.add_parser('article', help='import, list, edit or delete [article]')
parser_article = subparsers.add_parser('article', help='import, list, edit or delete article')
args = parser.parse_args()
print(vars(args))