May 2020
Intermediate to advanced
117 pages
1h 57m
English
Noah Gift
Writing command-line tools is one of my favorite ways to write code. A command-line tool is one of the simplest ways to take programming logic and create a flexible tool. Let’s walk through a simple click tool.
The following is an intentionally simple command-line tool that takes a flag --path (path to a file) and flag --ftype (file type). If this runs without specifying, it will prompt a user for both of these flags.
click based cli that searches for files: gcli.py#!/usr/bin/env python
import click
import glob
# this is bad code intentionally
# varbad=
@click.command()
@click.option(
"--path",
prompt="Path to search for files",
help="This is the path to search for files: ...Read now
Unlock full access