Sha256: 32122b0ff2283bc256e1737b74857643eaf4b4cd7f281de055e053e4bfecc87f

Contents?: true

Size: 1.56 KB

Versions: 5

Compression:

Stored size: 1.56 KB

Contents

require 'thor'

module Gamefic
  module Sdk
    class Shell < Thor
      map %w[--version -v] => :version
      map [:create, :new] => :init

      desc "--version, -v", "Print the version"
      def version
        puts "gamefic-sdk #{Gamefic::Sdk::VERSION}"
        puts "gamefic #{Gamefic::VERSION}"
      end

      desc 'init DIRECTORY_NAME', 'Create a new project in DIRECTORY_NAME'
      option :gem, type: :boolean, aliases: [:g, :library, :rubygem], desc: 'Make a gem project'
      option :specs, type: :boolean, desc: 'Add RSpec and Opal::RSpec test suites', default: true
      def init(directory_name)
        scaffold = options[:gem] ? 'library' : 'project'
        Gamefic::Sdk::Scaffold.build scaffold, directory_name, specs: options[:specs]
        puts "Gamefic project initialized at #{File.realpath(directory_name)}"
      end

      desc 'diagram TYPE', 'Get diagram data'
      long_desc %(
        SDK "diagrams" are datasets that can be used in analysis tools and
        graphical data representations. The dataset is provided in JSON
        format.

        The diagram types are entities, rooms, actions, verbs, syntaxes, and commands.
      )
      option :directory, type: :string, aliases: :d, desc: 'The project directory', default: '.'
      def diagram type
        main = Pathname.new(options[:directory]).join('main.rb').realpath.to_s
        require_relative main
        plot = Gamefic::Plot.new
        diagram = Gamefic::Sdk::Diagram.new(plot)
        puts diagram.get(type).to_json
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gamefic-sdk-3.4.1 lib/gamefic-sdk/shell.rb
gamefic-sdk-3.4.0 lib/gamefic-sdk/shell.rb
gamefic-sdk-3.3.0 lib/gamefic-sdk/shell.rb
gamefic-sdk-3.2.1 lib/gamefic-sdk/shell.rb
gamefic-sdk-3.2.0 lib/gamefic-sdk/shell.rb