Sha256: 44e86d19f14f769bda9f4f4b73f47e7c1340951c4f5d00c3090ec06a58af1fac

Contents?: true

Size: 1.77 KB

Versions: 1

Compression:

Stored size: 1.77 KB

Contents

#!/usr/bin/env ruby
STDOUT.sync = true

$LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w( .. lib ))

require 'bunto'
require 'mercenary'

Bunto::PluginManager.require_from_bundler

Bunto::Deprecator.process(ARGV)

Mercenary.program(:bunto) do |p|
  p.version Bunto::VERSION
  p.description 'Bunto is a static site generator and web application framework in Ruby'
  p.syntax 'bunto <subcommand> [options]'

  p.option 'source', '-s', '--source [DIR]', 'Source directory (defaults to ./)'
  p.option 'destination', '-d', '--destination [DIR]', 'Destination directory (defaults to ./_site)'
  p.option 'safe', '--safe', 'Safe mode (defaults to false)'
  p.option 'plugins_dir', '-p', '--plugins PLUGINS_DIR1[,PLUGINS_DIR2[,...]]', Array, 'Plugins directory (defaults to ./_plugins)'
  p.option 'layouts_dir', '--layouts DIR', String, 'Layouts directory (defaults to ./_layouts)'
  p.option 'profile', '--profile', 'Generate a Liquid rendering profile'

  Bunto::External.require_if_present(Bunto::External.blessed_gems) do |g|
    cmd = g.split('-').last
    p.command(cmd.to_sym) do |c|
      c.syntax cmd
      c.action do
        Bunto.logger.abort_with "You must install the '#{g}' gem to use the 'bunto #{cmd}' command."
      end
    end
  end

  Bunto::Command.subclasses.each { |c| c.init_with_program(p) }

  p.action do |args, _|
    if args.empty?
      Bunto.logger.error "A subcommand is required."
      puts p
      abort
    else
      subcommand = args.first
      unless p.has_command? subcommand
        Bunto.logger.abort_with "fatal: 'bunto #{args.first}' could not" \
          " be found. You may need to install the bunto-#{args.first} gem" \
          " or a related gem to be able to use this subcommand."
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bunto-3.0.0 bin/bunto