Sha256: f76bc05b9dfc76429094395b50085265d01be59878febc9109f38a94724dc302

Contents?: true

Size: 1.31 KB

Versions: 2

Compression:

Stored size: 1.31 KB

Contents

require 'thor'
require 'application'

module Docman
  class CLI < Thor

    # TODO: add proper descriptions.

    desc 'init NAME', 'init to NAME'
    def init(name, repo)
      if File.directory? "#{name}"
        say("Complete!", :green)
        $stderr.puts "Directory #{name} already exists"
        choice = ask('Are you sure you want do delete existing docroot?')
        FileUtils.rm_r(name) if choice == 'yes'
      end

      puts "Init docroot directory #{name} and retrieve config from provided repo."
      Application.instance.init(name, repo)
    end

    desc 'build NAME', 'init to NAME'
    method_option :force, :aliases => '-f', :desc => 'Force full rebuild'
    def build(deploy_target, state)
      config_dir?

      Application.instance.build(deploy_target, state, options)
    end

    desc 'deploy NAME', 'init to NAME'
    def deploy(deploy_target, name, type, version)
      config_dir?
      Application.instance.deploy(deploy_target, name, type, version)
    end

    desc 'state NAME', 'init to NAME'
    def state(name, type, version)
      config_dir?
      Application.instance.state(name, type, version)
    end

    no_commands {
      def config_dir?
        unless File.directory?('config')
          $stderr.puts 'ERROR: No config directory in docroot'
          exit 1
        end
      end
    }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
docman-0.0.4 lib/docman/cli.rb
docman-0.0.3 lib/docman/cli.rb