test(cli): validate mentions handle

This commit is contained in:
Peter Steinberger
2025-12-26 12:34:16 +01:00
parent 3df7969b16
commit 6669ba9912
4 changed files with 49 additions and 5 deletions
+17
View File
@@ -11,3 +11,20 @@ export function normalizeHandle(input?: string | null): string | null {
return handle;
}
export function mentionsQueryFromUserOption(userOption?: string | null): {
query: string | null;
error: string | null;
} {
if (typeof userOption === 'undefined') return { query: null, error: null };
const handle = normalizeHandle(userOption);
if (!handle) {
return {
query: null,
error: 'Invalid --user handle. Expected something like @steipete (letters, digits, underscore; max 15).',
};
}
return { query: `@${handle}`, error: null };
}