# LibTmux.Server.BuildGuardedCommandLine

- **Module:** LibTmux
- **Package:** LibTmux
- **Language:** C#
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-dotnet/blob/cf34b255c896d19a97e7d7fabea58609c916012d/src/LibTmux/Server.Command.cs#L65
- **Page:** https://libtmux.org/en/csharp/latest/reference/libtmux-server-buildguardedcommandline/

```
LibTmux.Server.BuildGuardedCommandLine(expected: ServerGeneration, mismatchCommand: string, IReadOnlyList<string>[]: IReadOnlyList<string>, commands) -> IReadOnlyList<string>
```

Builds the argument vector for a raw tmux invocation that only takes effect while the named server generation is still current.

A command this library dispatches itself is already guarded by
<see cref="TmuxCommand.RequiredGeneration" /> through
<see cref="Server.Chain" />. This is for the one case that cannot go
through that dispatch -- an interactive attach, which must run as its
own foreground process to inherit the caller's terminal, so the guard
has to travel inside the argument vector instead.

## Parameters

- `expected` (`ServerGeneration`): The generation the command requires.
- `mismatchCommand` (`string`): A tmux command run instead when the generation has changed. The caller
already committed to spawning a process expecting
<paramref name="expected" />, so this is typically one that fails
loudly rather than one that repairs anything.
- `commands`: One or more tmux commands to run when the generation still matches,
each its own argument vector.

## Returns

The encoded arguments. Prepend <see cref="EndpointArguments" /> before
passing this to a process started at
<see cref="ServerConnectionOptions.TmuxBinaryPath" />.
