---
title: "Rewriting the CLI in Rust: Was It Worth It?"
description: "Railway rewrote its Go/Cobra CLI in Rust for v3 because the old codebase had untyped, string-defined GraphQL queries, dynamically registered flags that forced ~120 error guards, and assumptions predating multi-service projects."
url: "https://swe.quest/articles/rewriting-the-cli-in-rust-was-it-worth-it-da1e555358ca943e"
canonical: "https://blog.railway.com/p/rust-cli-rewrite"
source: "Railway"
published: "2023-03-10"
difficulty: "medium"
kind: "Case study"
reading_minutes: 9
tags: ["rust","developer-tools","refactoring","go","graphql"]
---

# Rewriting the CLI in Rust: Was It Worth It?

A post on [Railway](https://swe.quest/sources/railway.md), published 2023-03-10, 9 min read, Case study. Original: [https://blog.railway.com/p/rust-cli-rewrite](https://blog.railway.com/p/rust-cli-rewrite)

## Summary

Railway rewrote its Go/Cobra CLI in Rust for v3 because the old codebase had untyped, string-defined GraphQL queries, dynamically registered flags that forced ~120 error guards, and assumptions predating multi-service projects. The Rust version uses clap derive structs with one file per command, a commands\_enum! macro to generate the subcommand enum, and schema-validated GraphQL types against the new Public API. User-facing gains include tables, fuzzy-select menus via inquire, a global --json flag and automatic non-interactive mode in CI. The hardest part turned out to be cross-platform release CI and install scripts, and the rewrite broke some users' CI along the way.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Rust](https://swe.quest/tags/rust.md) (Languages)
- [Developer tools](https://swe.quest/tags/developer-tools.md) (Engineering practices)
- [Refactoring & migrations](https://swe.quest/tags/refactoring.md) (Engineering practices)
- [Go](https://swe.quest/tags/go.md) (Languages)
- [GraphQL](https://swe.quest/tags/graphql.md) (Backend & APIs)

## Prerequisites

- Rust basics ([easy posts on Rust](https://swe.quest/tags/rust.md?difficulty=easy))
- Go basics ([easy posts on Go](https://swe.quest/tags/go.md?difficulty=easy))
- GraphQL basics ([easy posts on GraphQL](https://swe.quest/tags/graphql.md?difficulty=easy))

## Keywords

Railway, clap, Cobra, inquire, Nixpacks, Railway Public API

## Related posts

- [From Ruby to Node: Overhauling Shopify’s CLI for a Better Developer Experience](https://swe.quest/articles/from-ruby-to-node-overhauling-shopify-s-cli-for-a-better-developer-experience-c31f4bbd707f942e.md): Shopify Engineering · 2023-01-10 · Medium · 12 min read · Developer tools, TypeScript, JavaScript, Refactoring & migrations, Testing
  Shopify rewrote its CLI from Ruby to TypeScript on Node to reduce system requirements, unify the Theme, App and Hydrogen workflows, and stay easy for internal teams to contribute to.
- [Getting Started with Rust on Replit](https://swe.quest/articles/getting-started-with-rust-on-replit-af5d2f428a86b560.md): Replit · 2022-01-21 · Medium · 13 min read · Rust, Developer tools
  Replit's browser IDE can host a ready-made Rust workspace, demonstrated here with a small Cargo project built in one.
- [Our Experience Porting the YJIT Ruby Compiler to Rust](https://swe.quest/articles/our-experience-porting-the-yjit-ruby-compiler-to-rust-221d770c36dd7d35.md): Shopify Engineering · 2022-05-11 · Medium · 16 min read · Rust, Compilers, Ruby, Refactoring & migrations, C & C++
  Shopify's YJIT team ported the CRuby JIT compiler from about 11,000 lines of C99 to Rust because C's lack of modules, generics, containers and safe macros made a growing compiler hard to manage.
- [Migrating our Messages API to Rust](https://swe.quest/articles/migrating-our-messages-api-to-rust-9b451909ab785c36.md): Anthropic Engineering · 2026-11-25 · Medium · 24 min read · Rust, Refactoring & migrations, Performance engineering, Testing, AI for coding
  Anthropic migrated its production Messages API from Python to Rust, using the live Python service as an oracle because tests were incomplete and the API kept changing.
- [How to use Rust in ClickHouse: avoiding a full rewrite](https://swe.quest/articles/how-to-use-rust-in-clickhouse-avoiding-a-full-rewrite-e470754e07a213d4.md): ClickHouse · 2025-12-17 · Medium · 13 min read · Rust, C & C++, Build systems, Refactoring & migrations, Testing
  ClickHouse, a 1.5M-line C++ analytic database, is adopting Rust incrementally rather than rewriting.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
