Your Privacy

This site uses cookies to enhance your browsing experience and deliver personalized content. By continuing to use this site, you consent to our use of cookies.
COOKIE POLICY

Skip to main content

Consolidate Your Development Scripts by Writing Your Own CLI

Consolidate Your Development Scripts by Writing Your Own CLI
Back to insights

Do you have a list of shell or batch scripts sitting inside your codebase that perform development tasks? Have you ever had to implement the same script in a different language because most of your team uses Unix/Linux, but a fraction of your team uses Windows? Does your team store the scripts in various places or different languages?   

I recently reflected on this problem while working with a client on an application distributed across a few repositories. I produced a solution that helped overcome some of the script blight that was affecting our project. My solution was to build a Command Line Interface (CLI) for my team. Back in the day, building a CLI was tedious, but now it is easy! Let’s dig into the problems we were able to overcome by creating our own tooling!  

We had three different code repositories with scripts in each repository responsible for various development tasks on our project. One repository had a series of Docker configurations responsible for spinning up the stack for our application. Another repository had a series of scripts for generating code and generating types from our API. And finally, another project had a code for exporting information from an authentication service. If you need to run any of these scripts, the expectation is that you would change your directory to run the scripts in that other project. When I initially solved this problem, I wrote a shell script to alias a bunch of the scripts, so I had access to them across all the projects. It was a crude solution that barely worked. I am not great at writing shell scripts, so this solution certainly lacked polish. But the real problem was I moved over to working on a Windows laptop, and the shell scripts would not run in PowerShell, and more importantly, I didn’t want to change directories constantly. We needed something that felt native to our team, something in JavaScript.  

I went for the cross-platform JavaScript solution and decided to write my own NodeJS CLI. Usually, writing a CLI by hand in NodeJS is complicated. Fortunately, I already knew about Gluegun, which is a CLI builder that is open source. First, if you have never used Gluegun, one word to describe it is astonishing! I had used it previously to write generators. I have also used other popular tools like Plop.js and Yeoman. Gluegun gives you more freedom within the tool and is intuitive in a way that the other tools are not. It does not just do code generation either! It comes with a toolbox that gives you all things a good CLI needs. The toolbox contains methods for interacting with the file system, executing CLI commands, collecting input, and pretty-printing with colors, to name a few. Commands are all located in a single directory and can be extended by building plugins for your CLI. Honestly, I can go on for hours about how cool this tool is, and if you do not want to take my word for it, the AWS (Amazon Web Services) Amplify CLI team thinks it is cool too! Sorry, rant over!  

Using Gluegun, I was able to consolidate a few commands to help my development process a ton. I could execute scripts to launch my front end for local development, spin up my Docker containers, and launch a local windows application in one command. The best part is I did not have to change to three different directories to launch these services, and it will work for my team working with Unix/Linux or my team working on Windows. I can now run the tool for updating our types based on our API. In addition, I added some quality-of-life scripts for clearing out caches that I usually did by hand. The best part is that I can now share these scripts with my team by creating a new repository/package! I intend to add the generators that we previously wrote in Plop.js to be our one-stop-shop for developing our specific application.  

As our team adds new scripts, we will have a central location to put the scripts in for working with the application regardless of the repository the scripts directly influence. Now our team can write the scripts once and run them on Windows or Unix/Linux! And finally, we can start everything we need without changing directories 1000 times a day! 

 

Digging In

  • Digital Products

    TAG Panel: Differentiate Your Customer Experience

    Join the CX and Product Management Societies to hear from our panel of Human-Centered Design experts on the business value of Agentic AI.

  • Digital Products

    The Bloated SaaS Era: Paying More for Less While Businesses Wait

    SaaS was supposed to make business faster, smarter, and more efficient. Instead, it’s become bloated, expensive, and painfully slow to change. The platforms we rely on—Salesforce, Workday, SAP, and others—haven’t truly innovated in years. Yet, they demand massive investments in re-implementation, process re-engineering, and data migration just to keep up. It’s time to ask: Are […]

  • Digital Products

    Reid Braswell Joins UDig as Vice President, Software Engineering

    UDig is proud to welcome Reid Braswell as our new Vice President of Software Engineering. With over 13 years of experience in technology consulting, Reid brings deep expertise in digital transformation, modern software engineering, and client-focused solutions. His leadership and passion for solving complex challenges make him an exceptional addition to the UDig team. Reid’s […]

  • Digital Products

    Energy 2025 – Expansion of Fossil Fuels or Carbon Reduction?

    Now that the election is behind us, we have an opportunity to anticipate the possible effects on the energy industry under this new administration. What strategies will be impacted? What will remain the same? What opportunities can we take advantage of in 2025? This blog is meant to dig into these questions and provide some […]

  • Digital Products

    The Growing Importance of Digital Accessibility

    Embracing Digital Accessibility: A Moral and Business Imperative In today’s digital landscape, accessibility has become crucial for businesses and organizations. With increasing awareness and legal requirements, ensuring that digital products are accessible to all users, including those with disabilities, is not just a compliance issue but a moral imperative. At UDig, we champion ADA compliance […]

  • Digital Products

    Unlocking Business Potential: The Power of Custom Application Development

    Like any savvy business leader, you’re likely always on the lookout for tools to give your company a competitive edge. And in doing so, you’ve undoubtedly considered investing in custom application development. But the question is, how do you ensure that such a major investment in a custom web application development provides a strong return on […]