Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 22, 08:15 UTC
cli: refine missing-value tip
jkomyno committed
Feb 19, 2026 at 10:54 UTC
5b93076711b85d66812528607c7d89a86bf3769d
2 files changed
+48
-4
ts/packages/cli/src/bin.ts
+46
-4
@@ -1,11 +1,11 @@
1
import process from 'node:process';
2
-import { Cause, Console, Effect, Exit, Layer, Logger } from 'effect';
2
+import { Cause, Console, Effect, Exit, HashMap, Layer, Logger, Option } from 'effect';
3
import { captureErrors, prettyPrintFromCapturedErrors } from 'effect-errors/index';
4
-import { CliConfig, HelpDoc, ValidationError } from '@effect/cli';
4
+import { CliConfig, Command, HelpDoc, Usage, ValidationError } from '@effect/cli';
5
import { FetchHttpClient } from '@effect/platform';
6
import { BunContext, BunRuntime, BunFileSystem } from '@effect/platform-bun';
7
import type { Teardown } from '@effect/platform/Runtime';
8
-import { runWithConfig } from 'src/commands';
8
+import { rootCommand, runWithConfig } from 'src/commands';
9
import * as constants from 'src/constants';
10
import { ComposioCliConfig } from 'src/cli-config';
11
import { BaseConfigProviderLive, ConfigLive, extendConfigProvider } from 'src/services/config';
@@ -93,6 +93,48 @@ const runWithArgs = Effect.flatMap(runWithConfig, run => run(process.argv)) sati
93
unknown
94
>;
95
96
+const collectValueOptionNamesFromUsage = (usage: Usage.Usage, acc: Set<string>) => {
97
+ switch (usage._tag) {
98
+ case 'Named': {
99
+ if (Option.isSome(usage.acceptedValues)) {
100
+ for (const name of usage.names) {
101
+ if (name.startsWith('-')) {
102
+ acc.add(name);
103
+ }
104
+ }
105
+ }
106
+ return;
107
+ }
108
+ case 'Optional':
109
+ case 'Repeated': {
110
+ collectValueOptionNamesFromUsage(usage.usage, acc);
111
+ return;
112
+ }
113
+ case 'Alternation':
114
+ case 'Concat': {
115
+ collectValueOptionNamesFromUsage(usage.left, acc);
116
+ collectValueOptionNamesFromUsage(usage.right, acc);
117
+ return;
118
+ }
119
+ case 'Mixed':
120
+ case 'Empty': {
121
+ return;
122
+ }
123
+ }
124
+};
125
+
126
+const valueOptionNames = (() => {
127
+ const names = new Set<string>();
128
+ const visit = (command: Command.Command<unknown>) => {
129
+ collectValueOptionNamesFromUsage(Command.getUsage(command), names);
130
+ for (const [, subcommand] of HashMap.toEntries(Command.getSubcommands(command))) {
131
+ visit(subcommand);
132
+ }
133
+ };
134
+ visit(rootCommand);
135
+ return names;
136
+})();
137
+
138
/**
139
* CLI entrypoint, which:
140
* - runs the Effect runtime and sets up its runtime environment
@@ -108,7 +150,7 @@ runWithArgs.pipe(
150
Effect.catchIf(ValidationError.isValidationError, error => {
151
const text = HelpDoc.toAnsiText(error.error).trim();
152
const flagMatch = text.match(/Received unknown argument: '(-{1,2}[\w-]+)'/);
111
- if (flagMatch) {
153
+ if (flagMatch && valueOptionNames.has(flagMatch[1])) {
154
return Console.error(`Tip: ${flagMatch[1]} requires a value, e.g. ${flagMatch[1]} "value"`);
155
}
156
return Effect.void;
ts/packages/cli/src/commands/index.ts
+2
@@ -27,6 +27,8 @@ const $cmd = $defaultCmd.pipe(
27
])
28
);
29
30
+export const rootCommand = $cmd;
31
+
32
export const runWithConfig = Effect.gen(function* () {
33
const version = yield* getVersion;
34