One of the great presentations at YAPCNA 2012 was Miyagawa’s Becoming a Polyglot. One of the ideas that it brought up was the idea that it was OK to play around in other languages, contribute to said languages, and see what idea you could steal from them or contribute to them. So, it’s been a pleasure to start trying to contribute more to perl projects on github. I think I’ve even found a niche of projects I like to contribute to (GitHub commandline wrappers.) So, imagine my joy when I saw that today, a new CLI for github had been released.
Octogit is a CLI for github. It’s pretty new and it lets you do lots of neat basic things. It’s written in Python, a language I am absolutely not an expert in, but I can figure it out. So, I checkout out the github repository, clicked on issues, and found one I thought I could attempt. The one that struck my eye was Add command line gist support The fact is that this was a good issue for me to attempt for a number of reasons:
- It was similar to existing functionality in the project (listing issues, for example.)
- It had a nicely documented REST api (like all of github, really.)
- The complexity was low.
So, I forked the repo, and went to town. The first thing I realized was that I simply didn’t even know how a python project is really structured (that uses setup.py.) No matter, I simply edited the code, and deployed it to my box using ‘python setup.py install’. I’m sure there is a better way to do this, but I figured that this was going to be the fastest way for me not to get trapped down a rabbit hole of learning, and just solve a problem.
So, I started to figure it out. The cli.py file was the command line parsing, it imported the functions it used at the very top from core.py, and I just needed to add my handling in the appropriate places. Fortunately my instincts were right:
- Adding additional command line parsing was templated code from existing command line parsing
- Adding additional web service calls was cut/paste
- Displaying the additional content was cut/paste
The entire process took at most 30 minutes. It cracks me up however, that in such a short period of time, I learned so very much. I was trying to solve a real actual problem, and I was able to move quickly to do so. The things that I relearned and experienced were:
- How indenting works in python
- How string interpolation works in python
- How throwing / managing exceptions works in python
- How the requests library works (it’s so very nice)
- How the clint.textui library works
- which is awesome
- seriously, columns and colored by themselves are amazing
- How to open up a browser on my client machine from python
There was so much to learn! And it was awesomely fun. So, I commited my code and I sent a pull request. I don’t know that it’ll get accepted, it’s possible my code is garbage and I don’t know… But I can now honestly say I have at least attempted to contribute to an open source python project! Github polyglot, here I come!