Make a cup of coffee with Git Moshe Zadka Fri, 04/01/2022 - 03:00
Up
Git can do everything—except make your coffee. But what if it could?
Like most people, I already have a dedicated coffee brewing device listening to HTCPCP requests. All that is left is to hook Git up to it.
The first step is to write the client code, using httpx:
>>> import httpx
>>> result = httpx.request("BREW", "http://localhost:1111/")
>>> result.text
'start'
Ah, nothing nicer than a coffee pot starting to brew. You need to do a few more steps to make this available to git
.
A proper way to do it would be to put this in a package and use pipx
to manage it. For now, install httpx
into your user environment:
$ pip install --user httpx
Then put this code in a script:
#!/usr/bin/env python
# This script should be in ~/.bin/git-coffee
# Remember to chmod +x ~/.bin/git-coffee
import httpx
result = httpx.request("BREW", "http://10.0.1.22:1111/")
result.raise_for_status()
print(result.text)
Make sure that ~/.bin
is in your path:
$ (echo $PATH | grep -q ~/.bin) ||