import { createCommand } from '../../../types';
import { listSubcommand } from './list';
import { createWorkspaceSubcommand } from './create';
import { getWorkspaceSubcommand } from './get';
import { refreshWorkspaceSnapshotSubcommand } from './refresh';
import { updateWorkspaceSubcommand } from './update';
import { validateWorkspaceDependenciesSubcommand } from './validate-dependencies';
import { deleteWorkspaceSubcommand } from './delete';
import { getCommand } from '../../../command-prefix';

export const workspaceCommand = createCommand({
	name: 'workspace',
	aliases: ['workspaces', 'ws'],
	description: 'Manage Coder workspaces',
	tags: ['requires-auth'],
	requires: { auth: true, org: true },
	examples: [
		{
			command: getCommand('coder workspace list'),
			description: 'List all workspaces',
		},
		{
			command: getCommand(
				'coder workspace create "My Workspace" --repo https://github.com/org/repo'
			),
			description: 'Create a new workspace',
		},
		{
			command: getCommand('coder workspace get ws_abc123'),
			description: 'Show workspace details',
		},
		{
			command: getCommand('coder workspace delete ws_abc123'),
			description: 'Delete a workspace',
		},
		{
			command: getCommand('coder workspace validate-dependencies git,nodejs'),
			description: 'Validate workspace dependencies',
		},
	],
	subcommands: [
		listSubcommand,
		createWorkspaceSubcommand,
		getWorkspaceSubcommand,
		updateWorkspaceSubcommand,
		refreshWorkspaceSnapshotSubcommand,
		validateWorkspaceDependenciesSubcommand,
		deleteWorkspaceSubcommand,
	],
});
