Helper functions for formatting and displaying signed-in user account details and names in a command-line interface. Reuse when building authentication status displays for CLI tools.
// Source: https://github.com/autohandai/code-cli | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
/**
* @license
* Copyright 2026 Autohand AI LLC
* SPDX-License-Identifier: Apache-2.0
*/
import type { AuthUser, LoadedConfig } from '../types.js';
export function getSignedInUser(config?: LoadedConfig): AuthUser | null {
if (!config?.auth?.token || !config.auth.user) {
return null;
}
return config.auth.user;
}
export function formatUserDisplay(user: AuthUser): string {
const name = user.name?.trim();
const email = user.email?.trim();
if (name && email && name !== email) {
return `${name} (${email})`;
}
return name || email || user.id;
}
export function
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key