Protobuf VS JSON

Protocol buffer juga dikenal sebagai Protobuf adalah protokol yang dikembangkan Google secara internal untuk memungkinkan serialisasi dan deserialisasi data terstruktur antara berbagai layanan…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Building my first CLI on top of linear using GraphQL

So I decided to pick this up for a Friday Night Hack to not only make myself my productive, but the rest of my team. The goal of the project is to allow you to just see all the task/branch names from your terminal then do a git checkout -b <taskBranchName>. In my opinion, this is ideal for all devs not having to leave their terminal to see what task they have to do this sprint/cycle. The goal is for me never to look at linear unless i need more context for a ticket or reviewing cycles/sprints.

To do this I have to first build a command line interface (cli) that will interact with linear.app’s GraphQL API. Super excited to actually mess around and see their implementation. So first I started out with creating a token via the settings page in linear.app and setting up my repo. You can get your token by going to Settings > API > Create Key. Below is a screenshot of how it should look, and the outcome of me creating a key specifically for pylinear.

Then I started exploring the schema, trying to figure out which nodes I needed to get the branch-task name. So I realized that the branch-task is being generated via the team.branchFormat. In my CLI I would need to pull the format and list of task issued to me. After pulling all this data I would need to fit the task title, number, key into the format. Then allow the user to create a branch off this name. This is a perfect example for showing the beauty of graphql. In RESTful system, I’d probably have to make 3 different calls to get all this information. Now with graphql I just have to build 1 query and I get everything i need to build this feature. Below is the graphql query I constructed to allow me to get all my assigned tasks, metadata for the tasks, and branchFormat

Once I implemented my graphql query with all the information, I then needed to setup the boilerplate code for my CLI. I ended up building this using python and pip package called `click` which allows you to create sleek CLIs without having todo all the leg work with the help and formatting pages. Also needed to install gql’s pip package to make network request to the api. The integration was super easy literally got it working in my python console after 2 or 3 copy pastes. Once I got the click cli boilerplate to basically make the network calls after running this command linear get-task-branches . I was able to get the all my task to print out as follows.

initial print of branches

But to take step further, my users will want to be able to choose specifically which task they will be working on right now. So i decided to add a select flow with the pip package inquirier, which allow you to prompt the user a dropdown in the terminal, and allow them to pick an option. Below is the additional step I took to make it easier for the user to choose a task branch name.

Users can choose a task

Add a comment

Related posts:

Unconventional computing past and present

You probably know that you are using an automatic programmable Turing-complete Von Neumann architecture electronic synchronous binary computer. These are some of the qualities of conventional…

Top 5 Considerations When Setting up Your New CCM Technology

New technologies can be overwhelming to configure. Implemented incorrectly, organizations seldom realize the full value of their investment and often must seek replacement technology sooner than…

Iran to Remove Four Zeros from National Currency

The plan will be proposed to the Parliament as a double-urgent motion, the government spokesman Ali Rabiei said. The CBI says its governor, Abdolnasser Hemmati, has already made it clear for the…