clagraff / argparse

A Golang argument parser for command line arguments.
MIT License
24 stars 4 forks source link

support add_argument like python #46

Closed seqyuan closed 5 years ago

seqyuan commented 5 years ago

Is there a way like this?

def project_stat(args):
    pass

def delete_one_project_from_databse(args):
    pass

def main():
    parser=argparse.ArgumentParser(description='',
        formatter_class=argparse.RawDescriptionHelpFormatter)
    subparsers = parser.add_subparsers(dest='subparser_name',help='')

    stat_parser = subparsers.add_parser('stat', help='show flow line projects stat')
    stat_parser.add_argument('-p', dest='sub_project_id',default='', help='sub_project_id')
    stat_parser.set_defaults(func=project_stat)

    delete_parser = subparsers.add_parser('delid', help='delet one filter and analysisproject from database')
    delete_parser.add_argument('-spi', dest='sub_project_id',required=True, help='sub_project_id')
    delete_parser.set_defaults(func=delete_one_project_from_databse)
clagraff commented 5 years ago

That's an interesting suggestion.

Unfortunately, this project isn't really maintained anymore. It's kept around in case anyone had been using it previously, but otherwise im not making updates to it right now.

As such, I would encourage you to take a look at some alternatives that may best fit your needs.

My personal favorite is kingpin. Or if you want something still similar to python's argparse you could look at akamensky's argparse