Module: LanguageOperator::CLI::Commands::System::Schema
- Included in:
- Base
- Defined in:
- lib/language_operator/cli/commands/system/schema.rb
Overview
DSL schema export command
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/language_operator/cli/commands/system/schema.rb', line 12 def self.included(base) base.class_eval do desc 'schema', 'Export the DSL schema in various formats' long_desc " Export the Language Operator Agent DSL schema in various formats.\n\n The schema documents all available DSL methods, parameters, validation\n patterns, and structure. Useful for template validation, documentation\n generation, and IDE autocomplete.\n\n Examples:\n # Export JSON schema (default)\n langop system schema\n\n # Export as YAML\n langop system schema --format yaml\n\n # Export OpenAPI 3.0 specification\n langop system schema --format openapi\n\n # Show schema version only\n langop system schema --version\n\n # Save to file\n langop system schema > schema.json\n langop system schema --format openapi > openapi.json\n DESC\n option :format, type: :string, default: 'json', desc: 'Output format (json, yaml, openapi)'\n option :version, type: :boolean, default: false, desc: 'Show schema version only'\n def schema\n handle_command_error('generate schema') do\n # Handle version flag\n if options[:version]\n puts Dsl::Schema.version\n return\n end\n\n # Generate schema based on format\n format = options[:format].downcase\n case format\n when 'json'\n output_json_schema\n when 'yaml'\n output_yaml_schema\n when 'openapi'\n output_openapi_schema\n else\n Formatters::ProgressFormatter.error(\"Invalid format: \#{format}\")\n puts\n puts 'Supported formats: json, yaml, openapi'\n exit 1\n end\n end\n end\n\n private\n\n # Output JSON Schema v7\n def output_json_schema\n schema = Dsl::Schema.to_json_schema\n puts JSON.pretty_generate(schema)\n end\n\n # Output YAML Schema\n def output_yaml_schema\n schema = Dsl::Schema.to_json_schema\n puts YAML.dump(schema.transform_keys(&:to_s))\n end\n\n # Output OpenAPI 3.0 specification\n def output_openapi_schema\n spec = Dsl::Schema.to_openapi\n puts JSON.pretty_generate(spec)\n end\n end\nend\n" |