Menu

1 / 2

How to Make a Python CLI Tool in 10 Minutes

DEV Community·Jeffrey.Feillp·6 months ago
#zIFw4WkI
#python#cli#beginners#tutorial#parser
Reading 0:00
15s threshold

Jeffrey.Feillp

Build command-line tools with Python's argparse.

import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--input', required=True)
parser.add_argument('--output', default='output.txt')
args = parser.parse_args()
print(f'Processing {args.input}...')

Enter fullscreen mode Exit fullscreen mode

Packaging

pip install pyinstaller
pyinstaller --onefile mytool.py

Enter fullscreen mode Exit fullscreen mode

Distribute as single binary.