# SelectReplFn

**Kind:** Class

**Source:** [`packages/core/repl/native-functions/select-relp-fn.ts`](https://github.com/nestjs/nest/blob/master/packages/core/repl/native-functions/select-relp-fn.ts#L9)

**Part of:** [Core](subsystem-packages-core)

`SelectReplFn` is a native REPL function responsible for selecting and returning a NestJS `INestApplicationContext`. It provides the REPL layer with access to the active application context so commands can resolve and interact with registered providers.

**Extends:** `ReplFunction`

## Methods

| Method | Signature | Returns |
|---|---|---|
| `action` | `action(token: DynamicModule | Type<unknown>)` | `INestApplicationContext` |

## Properties

| Property | Type |
|---|---|
| `fnDefinition` | `ReplFnDefinition` |

## Diagram

```mermaid
graph LR
  User[REPL User] --> Command[REPL Command]
  Command --> SelectReplFn[SelectReplFn]
  SelectReplFn --> Context[INestApplicationContext]
  Context --> Providers[Nest Providers]
```

## Usage

```ts
import { SelectReplFn } from './native-functions/select-relp-fn';

// Create the native REPL function using the dependencies required by your setup.
const selectRepl = new SelectReplFn(/* REPL/application dependencies */);

// Retrieve the selected Nest application context.
const appContext = selectRepl.action();

// Resolve a provider from the active application context.
const myService = appContext.get(MyService);
await myService.run();
```

## AI Coding Instructions

- Keep `action()` focused on returning a valid `INestApplicationContext`; avoid placing command-specific business logic in this class.
- Preserve NestJS context typing so callers can safely use `context.get()` to resolve providers.
- Ensure the REPL has initialized or selected an application context before invoking `action()`.
- When adding REPL-native functions, follow the same small, single-purpose `action()` pattern for predictable command integration.

## How it works

## `SelectReplFn`

`SelectReplFn` is a built-in REPL function class that extends `ReplFunction`. Its function metadata registers it under the name `select`, with a signature of `(token: DynamicModule | ClassRef) => INestApplicationContext`. [packages/core/repl/native-functions/select-relp-fn.ts:9-15]

When a `ReplContext` initializes, it includes `SelectReplFn` among its built-in function classes. The context stores the resulting instance under its metadata name and places a bound `action` method in the REPL global scope, so users invoke it as `select(...)`. [packages/core/repl/repl-context.ts:128-129] [packages/core/repl/repl-context.ts:148-161] [packages/core/repl/repl-context.ts:168-184]
