CliClipboard Class — astro Architecture
Architecture documentation for the CliClipboard class in cli-clipboard.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 0298f775_eac8_8d68_fb9a_0a62fdf019ad["CliClipboard"] c4fcd5ce_4a96_8071_9d35_f40a368f2892["cli-clipboard.ts"] 0298f775_eac8_8d68_fb9a_0a62fdf019ad -->|defined in| c4fcd5ce_4a96_8071_9d35_f40a368f2892 555ff7f1_806c_237a_e51a_038b77b02e46["constructor()"] 0298f775_eac8_8d68_fb9a_0a62fdf019ad -->|method| 555ff7f1_806c_237a_e51a_038b77b02e46 3ad241c4_c0ac_6abd_74d9_bace3166794d["copy()"] 0298f775_eac8_8d68_fb9a_0a62fdf019ad -->|method| 3ad241c4_c0ac_6abd_74d9_bace3166794d
Relationship Graph
Source Code
packages/astro/src/cli/info/infra/cli-clipboard.ts lines 36–95
export class CliClipboard implements Clipboard {
readonly #operatingSystemProvider: OperatingSystemProvider;
readonly #commandExecutor: CommandExecutor;
readonly #logger: Logger;
readonly #prompt: Prompt;
constructor({
operatingSystemProvider,
commandExecutor,
logger,
prompt,
}: {
operatingSystemProvider: OperatingSystemProvider;
commandExecutor: CommandExecutor;
logger: Logger;
prompt: Prompt;
}) {
this.#operatingSystemProvider = operatingSystemProvider;
this.#commandExecutor = commandExecutor;
this.#logger = logger;
this.#prompt = prompt;
}
async copy(text: string): Promise<void> {
text = text.trim();
const platform = this.#operatingSystemProvider.name;
const input = await getExecInputForPlatform({
platform,
commandExecutor: this.#commandExecutor,
});
if (!input) {
this.#logger.warn('SKIP_FORMAT', 'Clipboard command not found!');
this.#logger.info('SKIP_FORMAT', 'Please manually copy the text above.');
return;
}
if (
!(await this.#prompt.confirm({
message: 'Copy to clipboard?',
defaultValue: true,
}))
) {
return;
}
try {
const [command, args] = input;
await this.#commandExecutor.execute(command, args, {
input: text,
stdio: ['pipe', 'ignore', 'ignore'],
});
this.#logger.info('SKIP_FORMAT', 'Copied to clipboard!');
} catch {
this.#logger.error(
'SKIP_FORMAT',
'Sorry, something went wrong! Please copy the text above manually.',
);
}
}
}
Domain
Source
Frequently Asked Questions
What is the CliClipboard class?
CliClipboard is a class in the astro codebase, defined in packages/astro/src/cli/info/infra/cli-clipboard.ts.
Where is CliClipboard defined?
CliClipboard is defined in packages/astro/src/cli/info/infra/cli-clipboard.ts at line 36.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free