---
title: arg
description: Mark one argv entry of a `command` that the input of the Effect fills.
---

# `arg`

Constant, in `@jr2/orchestrator/src/effect.ts`. It is an export of `@jr2/orchestrator`, on the [Authoring surface](../authoring-surface.md) page, in Effects.

```ts
const arg: <const N extends string>(name: N) => Arg<N>
```

Mark one argv entry of a `command` that the input of the Effect fills. `arg("file")` is one
argument: the value of the `file` key of the input, whatever its characters. No shell reads it.

The input of the Effect then has a string key for each `arg`. Give it in the `input` of the
`invoke`, or use `fromPick` to give it from a pick.

When it starts, with no string in the input for an entry, the Effect fails (its `onError`
route): `command "<slot>": argv slot <<name>> has no string value in its input (got <type>) —
map it in the invoke's input`. The angle brackets around the name are in the text.

**Returns**: The argv entry, for the argv list of `command`.

**Example**

```ts
import { arg, command, fail, jr2Setup, workspace, type Workspaced } from "@jr2/orchestrator";

type Input = Workspaced<{ file: string }, "app">;

const body = jr2Setup({
  types: {} as { context: Input; input: Input },
  actors: { lint: command(["npx", "eslint", arg("file")]), fail: fail() },
}).createMachine({
  id: "lint",
  context: ({ input }) => input,
  on: { "workspace.lost": ".lost" },
  initial: "lint",
  states: {
    lint: {
      invoke: { src: "lint", input: ({ context }) => ({ file: context.file }), onDone: "done" },
    },
    done: { type: "final" },
    lost: { invoke: { src: "fail", input: { reason: "the Sandbox is gone" } } },
  },
});

export const machine = workspace(body, {
  repos: { app: { url: "https://github.com/you/app.git" } },
  spec: () => ({ branch: "lint" }),
});
```

**See also**

- [Effects](../../concepts/effects.md)
- [Run a command or call a URL with an Effect](../../guides/run-a-command-or-call-a-url.md)
- [ADR-0067: An Effect is an actor slot, and runs at most once unless marked idempotent](../decisions/0067-an-effect-is-an-actor-slot-and-runs-at-most-once-unless-marked-idempotent.md)
