lib/docman/cli.rb in docman-0.0.2 vs lib/docman/cli.rb in docman-0.0.3
- old
+ new
@@ -1,26 +1,51 @@
require 'thor'
-require 'docman'
+require 'application'
module Docman
class CLI < Thor
+
+ # TODO: add proper descriptions.
+
desc 'init NAME', 'init to NAME'
def init(name, repo)
- puts "Init docroot directory #{name} and retrieve config from provided repo."
if File.directory? "#{name}"
- `rm -fR #{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
- `mkdir #{name} && cd #{name} && git clone #{repo} config`
+
+ puts "Init docroot directory #{name} and retrieve config from provided repo."
+ Application.instance.init(name, repo)
end
desc 'build NAME', 'init to NAME'
- def build(target, state)
- unless File.directory?('config')
- $stderr.puts 'ERROR: No config directory in docroot'
- exit 1
- end
+ method_option :force, :aliases => '-f', :desc => 'Force full rebuild'
+ def build(deploy_target, state)
+ config_dir?
- `cd config && git reset --hard && git clean -f -d && git pull origin master`
- Docman.new.build(target, state)
+ 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
\ No newline at end of file