Skip to content

Commit 22e17a6

Browse files
authored
feat(cli): Add interactive prompts for commands (#5170)
This PR improves the CLI's user experience by introducing an interactive mode for the `create`, `dryrun`, `deploy`, and `init` commands. ​ When a user runs one of these commands without providing all the required arguments, the CLI will now launch an interactive prompt to guide them through the missing options. This makes the CLI easier to use, as it no longer requires users to memorize all command-line arguments. ​ The interactive prompts are built using `inquirer` to provide a user-friendly selection list for known values (like function types or environments). ​ The interactive mode is enabled by default and can be disabled with the `--no-interactive` flag or by setting the `CI` environment variable, ensuring backward compatibility and scriptability. ​ Fixes NAN-4237 ​ Testing: 1. Run `npm install` to add the new `inquirer` dependency. 2. Run `nango create` without any arguments. Verify that you are prompted to select a function type, integration, and provide a name. 3. Run `nango dryrun` without any arguments. Verify that you are prompted to select an environment, a function, and a connection. 4. Run `nango deploy` without an environment. Verify that you are prompted to select one. 5. Run `nango init` without a path. Verify that you are prompted to enter one. 6. Run any of the above commands with the `--no-interactive` flag to confirm that the prompts are skipped and the command fails due to missing arguments. <!-- Summary by @propel-code-bot --> --- A shared Ensure utility now orchestrates the interactive prompts, translating missing-argument errors into actionable guidance while preserving non-interactive execution when required. <details> <summary><strong>Affected Areas</strong></summary> • packages/cli/lib/index.ts • packages/cli/lib/services/interactive.service.ts • packages/cli/lib/services/ensure.service.ts • packages/cli/lib/services/function-create.service.ts • packages/cli/lib/types.ts • packages/cli/lib/services/sdk.ts • packages/cli/lib/utils/errors.ts • packages/cli/tsconfig.json • packages/cli/package.json • docs/reference/cli.mdx • package-lock.json </details> --- *This summary was automatically generated by @propel-code-bot*
1 parent 93c334c commit 22e17a6

File tree

13 files changed

+1183
-49
lines changed

13 files changed

+1183
-49
lines changed

docs/reference/cli.mdx

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,50 @@ Get details about a specific command by running:
5353
nango [command] --help
5454
```
5555

56+
## Interactive Mode
57+
58+
The Nango CLI includes an interactive mode that prompts you for missing arguments. For example, if you run `nango create` without specifying the function type, integration, or name, the CLI will prompt you for them.
59+
60+
This mode is enabled by default when you're in an interactive terminal session.
61+
62+
### Usage Examples
63+
64+
**Interactive Usage:**
65+
66+
If you run a command without all the required arguments, the CLI will prompt you for them.
67+
68+
```bash
69+
# Running "nango create" without arguments
70+
$ nango create
71+
72+
? What type of function do you want to create?
73+
❯ sync
74+
action
75+
on-event
76+
```
77+
78+
**Non-Interactive (Explicit) Usage:**
79+
80+
You can provide all arguments upfront to bypass the interactive prompts. This is ideal for scripting.
81+
82+
```bash
83+
nango create --sync --integration my-api --name get-contacts
84+
```
85+
86+
### Disabling Interactive Mode
87+
88+
You can disable interactive mode in two ways:
89+
90+
1. **Using a flag:** Pass the `--no-interactive` flag to any command.
91+
```bash
92+
nango create --no-interactive
93+
```
94+
2. **In a CI environment:** Interactive mode is automatically disabled when the `CI` environment variable is set. This is the standard way to detect CI/CD environments.
95+
96+
### Backwards Compatibility
97+
98+
Interactive mode is fully backward compatible. If you provide all the required arguments for a command, the CLI will not prompt you for anything and will behave exactly as it did before.
99+
56100
## Flags & environment variables
57101

58102
Global command flags:
@@ -61,6 +105,9 @@ Global command flags:
61105
# Command flag to auto-confirm all prompts (useful for CI).
62106
# Note: Destructive changes (like removing a sync or renaming a model) requires confirmation, even when --auto-confirm is set. To bypass this restriction, the --allow-destructive flag can be passed to nango deploy.
63107
--auto-confirm
108+
109+
# Command flag to disable interactive mode.
110+
--no-interactive
64111
```
65112

66113
Environment variables:
@@ -85,4 +132,3 @@ NANGO_DEPLOY_AUTO_CONFIRM=false # Default value
85132
<Tip>
86133
**Questions, problems, feedback?** Please reach out in the [Slack community](https://nango.dev/slack).
87134
</Tip>
88-

0 commit comments

Comments
 (0)