Sha256: dcb51ae545bc1c78fed335143cc9484695fbc04be0a176e25220c84a5bc3c965

Contents?: true

Size: 1.16 KB

Versions: 22

Compression:

Stored size: 1.16 KB

Contents

#!/usr/bin/env ruby
ENV['RACK_ENV'] ||= 'development'
# load path
lib_path = File.expand_path('../../lib', __FILE__)
($:.unshift lib_path) unless ($:.include? lib_path)

require 'thor'
require 'hyperdrive'

module Hyperdrive
  class CLI < Thor
    include Thor::Actions

    desc "docs", "Generate docs in markdown based on your resources."
    method_option :input,  aliases: "\--in",  desc: "Specify the directory or file to generate docs for."
    method_option :output, aliases: "\--out", desc: "Specify the destination of the docs.", default: "docs/api.md"
    def docs
      input = File.expand_path(options[:input])
      
      if File.file?(input)
        require input
      elsif File.directory?(input)
        Dir.glob("#{input}/*.rb").each do |file|
          require file
        end
      else
        raise ArgumentError, "Input is neither a file nor a directory"
      end

      if hyperdrive.resources.empty?
        say "This API doesn't have any resources to document", :red
        return
      end

      data = Hyperdrive::Docs.new(hyperdrive.resources).output
      create_file(options[:output], data)
      say "Done!"
    end
  end
end

Hyperdrive::CLI.start

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
hyperdrive-0.0.25 bin/hyperdrive
hyperdrive-0.0.24 bin/hyperdrive
hyperdrive-0.0.23 bin/hyperdrive
hyperdrive-0.0.22 bin/hyperdrive
hyperdrive-0.0.21 bin/hyperdrive
hyperdrive-0.0.20 bin/hyperdrive
hyperdrive-0.0.19 bin/hyperdrive
hyperdrive-0.0.18 bin/hyperdrive
hyperdrive-0.0.17 bin/hyperdrive
hyperdrive-0.0.16 bin/hyperdrive
hyperdrive-0.0.15 bin/hyperdrive
hyperdrive-0.0.14 bin/hyperdrive
hyperdrive-0.0.13 bin/hyperdrive
hyperdrive-0.0.12 bin/hyperdrive
hyperdrive-0.0.11 bin/hyperdrive
hyperdrive-0.0.10 bin/hyperdrive
hyperdrive-0.0.9 bin/hyperdrive
hyperdrive-0.0.8 bin/hyperdrive
hyperdrive-0.0.7 bin/hyperdrive
hyperdrive-0.0.6 bin/hyperdrive