argument('file'); $workspaceSlug = $this->option('workspace'); $category = $this->option('category'); $includeSensitive = $this->option('include-sensitive'); $includeKeys = ! $this->option('no-keys'); // Resolve workspace $workspace = null; if ($workspaceSlug) { if (! class_exists(Workspace::class)) { $this->components->error('Tenant module not installed. Cannot export workspace config.'); return self::FAILURE; } $workspace = Workspace::where('slug', $workspaceSlug)->first(); if (! $workspace) { $this->components->error("Workspace not found: {$workspaceSlug}"); return self::FAILURE; } } // Warn about sensitive data if ($includeSensitive) { $this->components->warn('WARNING: Export will include sensitive values. Handle the file securely!'); if (! $this->confirm('Are you sure you want to include sensitive values?')) { $this->components->info('Export cancelled.'); return self::SUCCESS; } } // Determine format from extension $extension = strtolower(pathinfo($file, PATHINFO_EXTENSION)); $format = match ($extension) { 'yaml', 'yml' => 'YAML', default => 'JSON', }; $this->components->task("Exporting {$format} config", function () use ($exporter, $file, $workspace, $includeSensitive, $includeKeys, $category) { $content = match (strtolower(pathinfo($file, PATHINFO_EXTENSION))) { 'yaml', 'yml' => $exporter->exportYaml($workspace, $includeSensitive, $includeKeys, $category), default => $exporter->exportJson($workspace, $includeSensitive, $includeKeys, $category), }; file_put_contents($file, $content); }); $scope = $workspace ? "workspace: {$workspace->slug}" : 'system'; $this->components->info("Config exported to {$file} ({$scope})"); return self::SUCCESS; } /** * Get autocompletion suggestions. */ public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void { if ($input->mustSuggestOptionValuesFor('workspace')) { if (class_exists(Workspace::class)) { $suggestions->suggestValues(Workspace::pluck('slug')->toArray()); } } if ($input->mustSuggestOptionValuesFor('category')) { $suggestions->suggestValues(ConfigKey::distinct()->pluck('category')->toArray()); } } }