Building a Command-Line Interface (CLI) with argparse

This is a self-paced GK Digital Learning product. GK Digital learning products are created by world-class production and instructional design teams to deliver an experience that feels more like a classroom than traditional e-learning with hands-on activities for real-world results. In addition to high quality video content and hands-on labs you will have access to subject matter experts to ask questions for feedback and support.

In this course, you will learn how to build a command-line interface (CLI) with argparse (a module in the Python standard library) and with third-party packages that offer alternative approaches and extended functionality. You will learn about adding positional and optional arguments, and then move to advanced topics such as building custom types and custom actions.

This course is available as a subscription for a three-month period beginning at the time of purchase. It includes all course releases, updates, as well as 90 days of instructor support.

You can also purchase this course as part of the Python Developer Bundle or Developer Collection.

Pre-Requisites

A basic command of the Python language and its standard library.

Content

1. Intro to CLI
2. Advanced CLI
3. Alternatives and Gotchas

Objectives

What You'll Learn

  •  Build a CLI with argparse, docopt or click
  •  Add positional or optional arguments
  •  Assign a type and an action to each argument
  •  Write a custom type
  •  Write a custom action
  •  Configure arguments as mutually exclusive
  •  Resolve conflicting argument names

Target Audience

Python developers who wants to provide an effective and easy-to-maintain interface to a software product for their customers.