Posts Contact

Writing Bitbucket CLI

I have had many projects that utilizes Bitbucket as remote git repo and pipeline configs. While using their web app is alright. I have always wished for a CLI just like Github's

A CLI would limit my time for window switching, moving the mouse to a button or looking for a pipeline

I have had a look at few open source projects on Github for a Bitbucket CLI

While most of them worked fine I couldn’t find one that I can manage pipelines and pull requests in one CLI
CLI's link 

Choosing the programming languages

 

I was looking for a language that has

  • Good error handling
  • Can be released to multiple OSes
  • Easy to contribute to

 

My initial thought was using LUA since it is a light and can be used in many places

However it is not easy to create binaries for multiple OSes and may not be the best scaling solution

I have looked into other languages such as JavaScript using Node Js and python but they are not the most optimized languages and consume a lot of memory.

 

I have picked Golang since it is can be compiled to different Operating systems and has good error handling

At the start I was going to write the CLI without any frameworks but I didn’t want to reinvent the wheel for text completion for multiple terminals (bash, zsh, Powershell)

This is why I picked Cobra. It made it easier to add text completion for Pipelines’ names and branches’ names and other flags such as status filtering

 

Limitations

Since the CLI utilizes the Bitbucket API there limitation for what the CLI can do

While I can stop a pipeline via the API it doesn’t allow me to continue stopped pipelines or manual ones or reruning a pipeline

Another limitation which is more of logical one. I am not sure how I would show pull requests comments on in a CLI. There are multiple ways to do it such as showing a number of lines on around the comment

 

Future updates

  • custom formatting
  • more pagination options for limits
  • Handling the not found results