Command-line git client with fancy interface features! See the code at fgit.py.
Expanded from a tutorial workshop I did in Summer 2021 as part of UIUC Summer of Side Projects for a talk at UIUC GNU/Linux Users Group.
Note that this is an example project to demonstrate the wide variety of command-line interface building libraries that python has available. Of course, an actual client will account for more edge cases and a more extensive feature set.
Most of what's being done here with excellent Python libraries:
Questionary does a great job at all sorts of command line question asking. Checkboxes, autocomplete, validations, formatting ad much more. Here we're using it to present the list of files to select as checkboxes.
https://github.com/pwaller/pyfiglet is a port of figlet for setting up banners with ASCII art. We show the git fancy add banner with it.
plumbum does a lot of the heavy lifting in many python command-line based applications.
With plumbum.cmd, we can import bash scripts and call them as python functions. For example, here, we're using it to call ls to get the list of current files and git to execute our commands on it.
The cli module from plumbum also lets us use a nice class-based syntax to set a version number, flags, and help text that wrap around our script. This allows us to focus on the content of the program itself.
The article in the See More section is a good place to learn more about plumbum.
Another common library I've seen in python CLI applications is rich. It's really good at all sorts of text-based formatting, colors, tables, logs, progress bars, and UTF-8 support. fgit is using it for color and text style formatting, as well as displaying the progress bar at the end.
-
Building Beautiful Command-Line Interfaces with Python - Summary of many interesting libraries
-
Plumbum scripting - Deeper dive into plumbum for bash-like scripting in python. Pipes, background execution, colors, decorators
After cloning the repository
-
Have a recent version of
python3andpipinstalled. -
Install from the requirements file
$ pip install -r requirements.txt
Use python3 to just run it once the dependencies are set up.
$ python fgit.py [OPTIONS]If you like, you can make it an executable, add it to your path and indicate the language with a #! hash-bang to make the initial start command smaller.*
-h/--help- Get help text-v/--version- Get version-c/--commit- Commit files after adding-p/--push- Push files at the end


