# Command line

> Run your App's Commands with act, list them, read their help, and run them from the App's own binary in production.

This guide covers Tinka's command line. You will learn how to:

- Run Commands with `act`
- List Commands and read their help
- Run Commands from the App's binary, where `act` isn't installed
- Run Commands in scripts and CI without prompts
- Control colors

## Overview

A **Command** is an action you run from the terminal, such as generating the App's key or publishing the posts scheduled for today. Tinka gives every App a few Commands, and your App adds its own. You run them with `act` from the App's directory.

Every Command has two audiences. People get text, colors where the terminal shows them, and prompts for what's missing. Agents get [Agent mode](../../reference/agent-mode.md): no prompts and a single JSON result. You write each Command once, and both work.

## Run Commands

Run `act` with the Command's name, then its arguments and flags:

```sh
act posts:publish --limit 5
```

Inside an App, `act` builds the App and runs its binary with your arguments, so your App's own Commands run with the App's own version of Tinka. The build is cached: `act` rebuilds only when a source file changed, so a run usually starts in a few milliseconds.

Building and running the App runs its code, so the first time you run one of its Commands, `act` asks whether you trust the App's directory. Answer `y` once per App. In CI, or for an agent, run `act trust` in the App's directory first. See [act trust](../../reference/commands.md#act-trust).

The App's `main` function hands the arguments to the App with `Main`:

```go title="main.go"
package main

import (
	"os"

	"github.com/mucolabs/tinka"
)

func main() {
	app := tinka.New(tinka.HTTPConfig{})
	// Add routes, providers and Commands here.
	os.Exit(app.Main(os.Args[1:]))
}
```

With no arguments, the binary serves requests. With arguments, it runs the Command they name. The same binary therefore runs Commands in production, where `act` isn't installed:

```sh
./blog about
```

## List Commands

Run `act` alone, or `act --help`, to list the Commands, the App's own included:

```text title="Output"
Run the App's Commands

Usage:
  act <command> [flags]

Commands:
  about            Describe the App: versions, Mode and what its providers configure
  generate:key     Generate a random APP_KEY and write it to .env
  posts:publish    Publish the posts scheduled until now
  completion       Print a shell completion script

Flags:
  -h, --help     Show help
      --json     Print a single JSON result instead of text
      --version  Print the version
```

## Get help for a Command

Add `--help` after a Command's name, or put `help` before it, to see its arguments and flags:

```sh
act posts:publish --help
act help posts:publish
```

```text title="Output"
Publish the posts scheduled until now

Usage:
  act posts:publish [flags]

Flags:
      --limit int       Publish at most this many posts (default 100)
  -h, --help            Show help
      --json            Print a single JSON result instead of text
      --no-interaction  Never prompt; use defaults
```

A mistyped name fails with a suggestion:

```text title="Output"
Error: unknown flag: --limt.
  Did you mean --limit?
  Fix: Run `act posts:publish --help` to see usage
```

`act completion` prints a script that completes Command names and flags when you press Tab. See [Commands](../../reference/commands.md#completion) to load it.

## Run Commands without prompts

A Command asks for what you didn't pass, such as a missing name, when you run it in a terminal. In scripts and CI, nobody can answer, so Commands never prompt there: they use defaults, and fail with an error naming the flag to pass when an answer is required. Pass `--no-interaction` to get the same behavior in a terminal:

```sh
act make:controller posts --no-interaction
```

See [Prompts](prompts.md) for how Commands ask, and how each question maps to a flag.

## Control colors

Commands use colors only when they write to a terminal. Set `NO_COLOR` to any value to turn them off, or use a terminal with `TERM=dumb`:

```sh
NO_COLOR=1 act about
```

See also: [Creating Commands](commands.md), [Commands reference](../../reference/commands.md), [Agent mode](../../reference/agent-mode.md)
