Sha256: 08cda42c16db85fe2fcd9efd35bd2e3b2d7633334af40fe16b475527a76007ff
Contents?: true
Size: 1.4 KB
Versions: 2
Compression:
Stored size: 1.4 KB
Contents
# frozen_string_literal: true require "thor" require "speek/application" module Speek # Command Line Interface class CLI < Thor default_command :parse desc "parse [option] <path, ...>", "generate expected schema type" option :schema_type, type: :string, aliases: "-s", desc: "schema type like rbs graphql protobuf" option :output_file_path, type: :string, aliases: "-o", desc: "output file path" option :input_file_path, type: :string, aliases: "-i", desc: "input file path" def parse schema_type = options[:schema_type] output_file_path = options[:output_file_path] input_file_path = options[:input_file_path] if schema_type.nil? && input_file_path.nil? puts "must set schema type and input file path" exit 1 end unless File.file?(input_file_path) puts "should pass valid file path. `#{input_file_path}` dose not exist." exit 1 end app = Speek::Application.read(input_file_path) exporter = case schema_type&.to_sym when :rbs Export::Rbs when :gql, :graphql Export::Graphql else raise "no support pattern" end code = exporter.new(app).export if output_file_path.present? File.new(output_file_path).write(code) else puts code end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
speek-0.1.1 | lib/speek/cli.rb |
speek-0.1.0 | lib/speek/cli.rb |