'use strict';

/**
 * Contract: catalog dashboard
 *
 * Output JSON catalog struktur payload dashboard (allowed/forbidden fields,
 * widget structure, param contract, scalar collapse rules, naming, URL pattern,
 * file reference + placeholder convention).
 *
 * Inline migration v4.0.0: business logic asli dari dashboard-catalog.js
 * di-inline langsung di handler. Adapter argv override dihapus karena handler
 * langsung pakai args.pretty.
 */

const { DASHBOARD_CATALOG } = require('../../lib/templates/dashboard-catalog');

module.exports = {
    resource: 'catalog',
    verb: 'dashboard',
    description: 'Output JSON catalog struktur payload dashboard',
    category: 'introspection',
    flags: {
        pretty: {
            type: 'boolean',
            required: false,
            default: true,
            description: 'Pretty-print output JSON'
        }
    },
    examples: [
        'npx restforge catalog dashboard',
        'npx restforge catalog dashboard --pretty=false'
    ],
    async handler(args) {
        const pretty = args.pretty !== false;
        const json = pretty
            ? JSON.stringify(DASHBOARD_CATALOG, null, 2)
            : JSON.stringify(DASHBOARD_CATALOG);
        console.log(json);
    }
};
