Good news for developers: The CLI is back

The command line interface is enjoying a renaissance among software companies, making life easier for developers.
Written by Simon Bisson, Contributor

Back when I started writing code, everything was done in the command line. You configured systems with the command line, wrote scripts in vi and emacs and ed, building your own library of commands that simplified your tasks and automated the complex. Armed with a copy of Kernigan and Pike's The Unix Programming Environment, or its DOS equivalent, the world was your oyster.

But over the years everything changed. Windows (with and without an X) made it all a matter of pointing and clicking and pointing and clicking and pointing and clicking. It was easy to get lost, and easier still to make an error and not notice that you'd forgotten to select a file or choose the correct value. It's impossible to quantify how much time I lost switching from dialog box to dialog box and from window to window.

But now command lines are back, running in our IDEs and editors, or in desktop shells. Support for Unix in familiar operating systems (BSD under the hood macOS and Linux in Windows' WSL) makes running command lines easy, and bash scripts are back again as the flavor of the month, as is Microsoft's own system administration-focused PowerShell, itself a cross-platform tool.

SEE: Six in-demand programming languages: Getting started (free PDF)

The CLI renaissance is particularly important for developers. Tools like Salesforce's CLI have made it easier to build and test applications on the Salesforce platform. Similarly, Azure's CLI allows you to use scripts and commands to manage and configure your services and your virtual infrastructures. They're quick to learn, and easy to use to build libraries of commonly used commands. They can even integrate into the new generation of development tools like Visual Studio Code.

That combination of editor and CLI is a powerful one, you can be writing code in one pane, testing it in a tab of another, while using a built-in terminal window to configure services at the same time. There's no jumping between apps, or even between windows; the combination of CLI and editor helps you keep in flow, reducing the risk of distractions and of losing that enigmatic but essential flow state.

One of the latest CLIs to be released is Twilio's, giving you a way of managing your Twilio resources without having to have a permanent connection open to the Twilio dashboard. It's easy enough to install, through Homebrew on macOS or via npm on node.js on Windows or Linux (Windows users might prefer to install it under WSL, especially if you're using the previews of the new WSL2). You will initially need to provide your account SID and an authentication token before you can get started; once they're linked to your Twilio CLI install they're used to create and store a local API key that handles access in future.

If you're using bash, in Linux, WSL, or older macOS installs, you can quickly install autocomplete options. The same options are available in macOS Catalina or Linux installs using zsh. You'll need to restart your terminal to get access to autocomplete.

Once installed you get access to tools that help you work with Twilio. All you need is the twilio keyword; typing it without any additional options gives you a high-level help view of the main functions of the CLI tooling. You can use it to work with the APIs, with your account, and manage your assigned phone numbers. There's even the option to add plugins to the CLI for additional functionality. To get more detail on each section of the CLI, use the same method to get a list of the options for the command you're using, with –help giving you the most detail.

Perhaps the most useful aspect of the CLI is the ability to try out specific Twilio functions before you commit them to code. For example, you can use it to quickly test whether you have the right syntax to send SMS messages, as well as buying new phone numbers. Other options let you quickly add webhooks to a phone number, and even use Twilio's recent acquisition SendGrid's mail APIs.

The Twilio CLI's plugin architecture simplifies working with tools like Twilio's serverless Functions. Once installed it adds tools for creating serverless environments, as well as well as deploying code from your development system to Twilio's cloud platform. Installing the plugin installs a local server for Functions, so you don't need to run up unexpected bills while you're developing new code.

It's part of Twilio's serverless toolkit and runs on top the same node.js runtime as the CLI. Once installed, you first need to create a project and then begin working in the project directory. It sets up the appropriate scaffolding for your app, in the correct directories. You can add your own dependencies using npm to update the configuration files and download the libraries.

SEE: Verified by Twilio will tell you who's calling -- and why

Your Function is a JavaScript app, which can be tested locally, allowing you to build code in your favorite editor, building on Twilio's own function templates from GitHub. Once your code is ready, a single command uploads it to Twilio's serverless environment, ready for use.

Twilio's support for command line tools fits in with current trends in application development. By adding a new set of commands to your current command line environment there's no need to change your toolchain, you're getting extra functionality – whether it's providing application frameworks and scaffolding or giving you a way to test and manage API functions. What really matters is that Twilio's new tools should make you more productive, and that is definitely a worthwhile goal.

Editorial standards