Type CLI command host/json options at the source
The CommandOptions interface in packages/cli/src/output/with-output.ts had an open `[key: string]: unknown` indexer, so every consumer of the global --host and --json options had to cast `options.host as string | undefined` at the call site. Add `host?: string` and `json?: boolean` to the interface and remove 29 redundant casts across 12 command files.
This commit is contained in:
@@ -166,7 +166,7 @@ export async function runSendCommand(
|
||||
options: AgentSendOptions,
|
||||
_command: Command,
|
||||
): Promise<SingleResult<AgentSendResult>> {
|
||||
const host = getDaemonHost({ host: options.host as string | undefined });
|
||||
const host = getDaemonHost({ host: options.host });
|
||||
|
||||
// Validate arguments
|
||||
if (!agentIdArg || agentIdArg.trim().length === 0) {
|
||||
@@ -186,7 +186,7 @@ export async function runSendCommand(
|
||||
|
||||
let client;
|
||||
try {
|
||||
client = await connectToDaemon({ host: options.host as string | undefined });
|
||||
client = await connectToDaemon({ host: options.host });
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
const error: CommandError = {
|
||||
|
||||
Reference in New Issue
Block a user