This document provides an overview of command line interface (CLI) applications and compares different libraries for building CLIs in Python: Argparse, Click, and Docopt. It discusses some limitations of scripts and advantages of CLI applications, then gives code examples and explanations of each library.
12. print("This is important code")
1
2
for index, arg in enumerate(sys.argv):
3
print(f"[{index}]: {arg}")
4
What's Wrong with Scripts?
Easy to get started
Limited possibilities for structure
Hard to (unit) test
No dependency management
Deployment may require care
Custom user experience
13. print("Usage: foo <bar> --baz")
def main():
1
2
3
if __name__ == "__main__":
4
main()
5
Why CLI Applications?
Standardized user experience
More possibilities for structure
Possibilities for all kinds of testing
Dependency management
Packaging & distribution
18. Thank you!
for your precious time
Painless Software
Less pain, more fun.
Most images taken from Wikipedia (CC-SA)
Alberto Sordi animated GIF stolen from giffetteria.it