mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
21 lines
655 B
TypeScript
21 lines
655 B
TypeScript
import type { ShellCommand, ShellCommandResult } from "./ShellCommand";
|
|
import { createSuccessResult, createErrorResult } from "./ShellCommand";
|
|
|
|
/**
|
|
* Implementation of the 'whoami' command
|
|
* Display current username
|
|
*/
|
|
export class WhoamiCommand implements ShellCommand {
|
|
name = 'whoami';
|
|
description = 'Display current username';
|
|
usage = 'whoami';
|
|
|
|
async execute(args: string[], _cwd: string, _input?: string): Promise<ShellCommandResult> {
|
|
// whoami doesn't accept any arguments
|
|
if (args.length > 0) {
|
|
return createErrorResult(`${this.name}: extra operand '${args[0]}'`);
|
|
}
|
|
|
|
return createSuccessResult('user\n');
|
|
}
|
|
} |