Python Classroom Series – 15/Sept/2021

Building Command Line Interfaces with argparse

  • In python we have a standard library argparse to parse the arguments
  • Refer Here for how to use arg parse
  • using Python standard argparse libarary
    • Create the parser
    • Add optional (keyword) and positional arguments to the parser
    • Execute .parse_args
  • Refer Here for the simple argument parser created as a demo

Scenario

  • Lets try to write a cli application which
    • allows books to be added to the database
    • allows books to be updated/deleted/
    • allows books to be queried
  • Lets design cli first
books add --title <name> --author <author>
books get --title <name> --author <author>
books update -id <id of book> --title <new name> --author <new author>

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin