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