---
title: "CLI Flags in Practice + How to Make Your Own CLI Command with oclif"
description: "CLI commands commonly accept arguments, long flags, short flags, and flag arguments; environment variables and standard input are alternative data channels not covered in detail. GNU-style conventions use double dashes for long flags and single dashes for short flags; short flags can be stacked, and flag options may be separated by a space or equals sign, while short flags also allow no separator. The tutorial uses oclif to build greet-me, which prints a greeting based on a name supplied through -n or --name while registering version, help, name, and force flags. It scaffolds the project with npx oclif single greet-me, places handling code in src/index.ts, defaults the name to world, and runs the CLI through ./bin/run or an npm link."
---

# CLI Flags in Practice + How to Make Your Own CLI Command with oclif

[Heroku](https://yomu.fyi/company/heroku) · Casey Watts · May 9, 2019

**Type:** Tutorial

## Summary

CLI commands commonly accept arguments, long flags, short flags, and flag arguments; environment variables and standard input are alternative data channels not covered in detail. GNU-style conventions use double dashes for long flags and single dashes for short flags; short flags can be stacked, and flag options may be separated by a space or equals sign, while short flags also allow no separator. The tutorial uses oclif to build greet-me, which prints a greeting based on a name supplied through -n or --name while registering version, help, name, and force flags. It scaffolds the project with npx oclif single greet-me, places handling code in src/index.ts, defaults the name to world, and runs the CLI through ./bin/run or an npm link.

## Context

CLI parameters can be difficult to understand and design ergonomically. The material introduces the common parts of a command so users can make fewer typos and understand shared commands more quickly, while CLI designers can create clearer user interfaces.

## Approach / What changed

It explains arguments, long and short flags, flag arguments, and their syntax using ls, tar, and git examples, then scaffolds a greet-me CLI with npx oclif single greet-me. The implementation registers flags in an oclif command class, defaults the name to world, and runs the CLI directly or through npm link.

## Takeaways

- Long flags use two dashes and multiple characters, while short flags use one dash and one letter; short flags can be stacked, as in ls -la.
- A flag option must immediately follow the flag and can be separated by a space or equals sign; short flags may also attach the option directly, as in tar -farchive.tar.
- The generated oclif command registers version, help, name, and force flags, and its name flag supports both -n and --name forms.

**Tags:** [Node.js](https://yomu.fyi/topic/node-js), [oclif](https://yomu.fyi/topic/oclif), [TypeScript](https://yomu.fyi/topic/typescript)

- Source: [Heroku](https://www.heroku.com/blog/cli-flags-get-started-with-oclif)
- Source URL: https://www.heroku.com/blog/cli-flags-get-started-with-oclif
- Ingested by Yomu: 2026-09-09T14:27:31.224Z

[Read original post](https://www.heroku.com/blog/cli-flags-get-started-with-oclif)
