Skip to content

Commit 4b82e85

Browse files
committed
feat: 🎸 add .info method
1 parent a9aa9de commit 4b82e85

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

‎src/codecs/raw.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export class CliCodecRaw implements CliCodec<'raw'> {
66

77
encode(value: unknown): Uint8Array {
88
if (value instanceof Uint8Array) return value;
9-
const str = String(value);
9+
const str = String(value) + '\n';
1010
return new TextEncoder().encode(str);
1111
}
1212

‎src/methods.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,19 @@ export const defineBuiltinRoutes = <Routes extends ObjectType<any>>(r: ObjectVal
2323
return (ctx as CliContext).cli.types.exportTypes();
2424
},
2525
),
26+
27+
r(
28+
'.info',
29+
t.Function(t.undef, t.any).options({
30+
title: 'CLI information',
31+
description: 'Returns whole information about this CLI.',
32+
}),
33+
async (request, ctx) => {
34+
return {
35+
version: (ctx as CliContext).cli.options.version,
36+
cmd: (ctx as CliContext).cli.options.cmd,
37+
};
38+
},
39+
),
2640
]);
2741
};

‎src/params/CliParamHelp.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ the "--stdout" or "--out" option.
3939
Usage:
4040
4141
${cmd} <method> '<json>'
42-
echo '<json>' | ${cmd} <method>
4342
${cmd} <method> --<type><pointer>=<value>
43+
echo '<json>' | ${cmd} <method>
4444
4545
Examples:
4646

0 commit comments

Comments
 (0)