Skip to content

argparse extension to allow command suggestions for invalid commands

License

Notifications You must be signed in to change notification settings

xmonader/suggestparse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

suggestparse

argparse extension to allow command suggestions for invalid commands based on difflib closest_matches function.

Installation

To install pip install suggestparse

Example

def test():
    parser = SuggestingArgumentParser()
    parser.add_argument('--add', '-a', help='add')
    parser.add_argument('--edit', '-e', help='edit')
    parser.add_argument('--delete', '-d', help='delete')
    parser.add_argument('--view', '-v', help='view')
    print(parser.parse_args())

if __name__ == '__main__':
    test()

So if you type --vew by accident or things like git comit or git clon you will see something like that.

$ python3 suggestparse.py --vew                                                                      
Did you mean:  ['--view']
usage: suggestparse.py [-h] [--add ADD] [--edit EDIT] [--delete DELETE]
                       [--view VIEW]
suggestparse.py: error: unrecognized arguments: --vew

About

argparse extension to allow command suggestions for invalid commands

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages