Command line applications let you run programs from the command line or [[shell]]. You will often see command line tools distributed for specific software called a [[command line interface]] (CLI). I use the term command line tool to describe specifically the software that runs when you call the software using commands from the command line. ## run a python program from the command line The easiest way to use the command line to run Python programs is simply to write a script and run it from a shell (like [[Bash]]). ``` python <my_app.py> ``` If you don't want to provide the fully-qualified path to your script, open the shell from within the project's directory, or `cd` into it. See [[add application to context menu]] to easily launch Bash from a specific directory. If you need to pass arguments to your application (e.g., a file to save output), you'll need to be able to handle those arguments. The command line will pass anything you type after `python <my_app.py>` as strings to the program, but without a way of parsing and validating those strings, those arguments just get ignored. There are a number of packages that you can explore for developing command line tools: * `fire` * `argpars` * `click` `fire` may be the easiest to use right out of the box, while `click` has more control for validation and providing help at the command line. > [!Example] Additional Resources > - [How to write python command line interfaces like a pro](https://towardsdatascience.com/how-to-write-python-command-line-interfaces-like-a-pro-f782450caf0d) > - [Python command line tools](https://opensource.com/article/18/5/3-python-command-line-tools)