Skip to content

The open alternative to Salesforce, designed for AI.

Explain remote setup in CLI help (#28557)

Weiko9407892a8bdf
diff --git a/packages/twenty-cli/src/catalog/command-topics.ts b/packages/twenty-cli/src/catalog/command-topics.ts
index 59ac2dabae6..5ce30fcc423 100644
--- a/packages/twenty-cli/src/catalog/command-topics.ts
+++ b/packages/twenty-cli/src/catalog/command-topics.ts
@@ -1,5 +1,6 @@
import { HELP_GROUP } from '@/catalog/constants/help-group.constant';
import { type CommandTopicDefinition } from '@/catalog/types/command-topic-definition.type';
+import { AUTH_LOGIN_COMMAND_DEFINITION } from '@/commands/auth/login/auth-login.command-definition';
export const COMMAND_TOPICS: CommandTopicDefinition[] = [
{
@@ -25,6 +26,9 @@ export const COMMAND_TOPICS: CommandTopicDefinition[] = [
path: ['remote'],
description: 'Manage saved workspace connections',
helpGroup: HELP_GROUP.WORKSPACE,
+ helpHint:
+ 'Add a remote using browser sign-in or an API key. See: twenty auth login --help',
+ examples: AUTH_LOGIN_COMMAND_DEFINITION.examples,
},
{
path: ['metadata'],
diff --git a/packages/twenty-cli/src/catalog/types/command-topic-definition.type.ts b/packages/twenty-cli/src/catalog/types/command-topic-definition.type.ts
index c1e84173bcc..43738878218 100644
--- a/packages/twenty-cli/src/catalog/types/command-topic-definition.type.ts
+++ b/packages/twenty-cli/src/catalog/types/command-topic-definition.type.ts
@@ -2,4 +2,6 @@ export type CommandTopicDefinition = {
path: string[];
description: string;
helpGroup?: string;
+ helpHint?: string;
+ examples?: string[];
};
diff --git a/packages/twenty-cli/src/commands/auth/login/auth-login.command-definition.ts b/packages/twenty-cli/src/commands/auth/login/auth-login.command-definition.ts
index 4932589a642..5e1227067d6 100644
--- a/packages/twenty-cli/src/commands/auth/login/auth-login.command-definition.ts
+++ b/packages/twenty-cli/src/commands/auth/login/auth-login.command-definition.ts
@@ -24,8 +24,8 @@ export const AUTH_LOGIN_COMMAND_DEFINITION: LocalCommandDefinition = {
],
examples: [
'twenty auth login --url https://acme.twenty.com',
- 'twenty auth login --url https://acme.twenty.com --name prod',
- 'printf \'%s\' "$TWENTY_API_KEY" | twenty auth login --with-token --url https://acme.twenty.com --name prod',
+ 'twenty auth login --url https://acme.twenty.com --name prod --use',
+ 'printf \'%s\' "$TWENTY_API_KEY" | twenty auth login --with-token --url https://acme.twenty.com --name prod --use',
'twenty auth login --with-token --remote prod < api-key.txt',
],
outputModes: ['human', 'json'],
diff --git a/packages/twenty-cli/src/program/format-examples.ts b/packages/twenty-cli/src/program/format-examples.ts
new file mode 100644
index 00000000000..f8eb4b2a1d7
--- /dev/null
+++ b/packages/twenty-cli/src/program/format-examples.ts
@@ -0,0 +1,2 @@
+export const formatExamples = (examples: string[]) =>
+ `\nExamples:\n${examples.map((example) => ` ${example}`).join('\n')}\n`;
diff --git a/packages/twenty-cli/src/program/register-command.ts b/packages/twenty-cli/src/program/register-command.ts
index 638c26e6a69..9400672a131 100644
--- a/packages/twenty-cli/src/program/register-command.ts
+++ b/packages/twenty-cli/src/program/register-command.ts
@@ -6,6 +6,7 @@ import { type CommandDefinition } from '@/catalog/types/command-definition.type'
import { type CommandOptionDefinition } from '@/catalog/types/command-option-definition.type';
import { type OutputMode } from '@/output/types/output-mode.type';
import { getCommandByPath } from '@/program/find-command-by-path';
+import { formatExamples } from '@/program/format-examples';
import { runCommand } from '@/program/run-command';
import { throwParseErrorOnExit } from '@/program/throw-parse-error-on-exit';
@@ -33,9 +34,6 @@ const createOption = ({
return option;
};
-const formatExamples = (examples: string[]) =>
- `\nExamples:\n${examples.map((example) => ` ${example}`).join('\n')}\n`;
-
export const registerCommand = ({
program,
definition,
diff --git a/packages/twenty-cli/src/program/register-topic.ts b/packages/twenty-cli/src/program/register-topic.ts
index c97fa82de01..c564e06db71 100644
--- a/packages/twenty-cli/src/program/register-topic.ts
+++ b/packages/twenty-cli/src/program/register-topic.ts
@@ -1,8 +1,9 @@
import { type Command } from 'commander';
-import { isDefined } from 'twenty-shared/utils';
+import { isDefined, isNonEmptyArray } from 'twenty-shared/utils';
import { type CommandTopicDefinition } from '@/catalog/types/command-topic-definition.type';
import { getCommandByPath } from '@/program/find-command-by-path';
+import { formatExamples } from '@/program/format-examples';
import { throwParseErrorOnExit } from '@/program/throw-parse-error-on-exit';
export const registerTopic = ({
@@ -21,5 +22,13 @@ export const registerTopic = ({
topicCommand.helpGroup(topic.helpGroup);
}
+ if (isDefined(topic.helpHint)) {
+ topicCommand.addHelpText('after', `\n${topic.helpHint}`);
+ }
+
+ if (isNonEmptyArray(topic.examples)) {
+ topicCommand.addHelpText('after', formatExamples(topic.examples));
+ }
+
throwParseErrorOnExit(topicCommand, topic.path.join(' '));
};