Menu

Post image 1
Post image 2
1 / 2
0

How to Make a Python CLI Tool in 10 Minutes

DEV Community·Jeffrey.Feillp·30 days ago
#zIFw4WkI
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.

Read More