Class: Docman::CLI
- Inherits:
-
Thor
- Object
- Thor
- Docman::CLI
- Defined in:
- lib/docman/cli.rb
Instance Method Summary collapse
- #build(deploy_target = "git_target", state = "") ⇒ Object
-
#bump(state = nil) ⇒ Object
option :state option :skip.
- #deploy(deploy_target, name, type, version) ⇒ Object
- #drush(drush_alias, command) ⇒ Object
- #info(command, file) ⇒ Object
- #init(name, repo) ⇒ Object
- #template(name = nil) ⇒ Object
Instance Method Details
#build(deploy_target = "git_target", state = "") ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/docman/cli.rb', line 48 def build(deploy_target="git_target", state="") docman_state_var = "RELEASE_STATE" if ENV.has_key? docman_state_var and ENV[docman_state_var].length > 0 state = ENV[docman_state_var] end if state.length > 0 get_to_root_dir if [:force] FileUtils.rm_rf('master') if File.directory? 'master' end Application.instance.build(deploy_target, state, ) say('Complete!', :green) else say("Cant build without state parameter or #{docman_state_var} environment variable.") end end |
#bump(state = nil) ⇒ Object
option :state option :skip
88 89 90 91 92 93 94 95 96 |
# File 'lib/docman/cli.rb', line 88 def bump(state = nil) bump_params = [] bump_params.push("--branch=#{[:branch]}") if [:branch] bump_params.push("--tag=#{[:tag]}") if [:tag] bump_params.push('--next') if [:next] and (not .has_kay? :tag or [:tag].empty?) bump_params.push('--skip') if [:skip] system "#{Application::bin}/bump-version.sh #{bump_params.join(' ')} #{state}" say('Complete!', :green) end |
#deploy(deploy_target, name, type, version) ⇒ Object
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/docman/cli.rb', line 70 def deploy(deploy_target, name, type, version) get_to_root_dir if version.start_with?('state_') state = version.partition('_').last build(deploy_target, state) else result = Application.instance.deploy(deploy_target, name, type, version, ) say(result, :green) end end |
#drush(drush_alias, command) ⇒ Object
110 111 112 113 114 115 |
# File 'lib/docman/cli.rb', line 110 def drush(drush_alias, command) env = drush_alias.partition('.').first.partition('@').last site = drush_alias.partition('.').last Application.instance.drush(env, site, command) say('Complete!', :green) end |
#info(command, file) ⇒ Object
122 123 124 125 |
# File 'lib/docman/cli.rb', line 122 def info(command, file) say(Application.instance.info(command, file, ).to_json); # say('Complete!', :green) end |
#init(name, repo) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/docman/cli.rb', line 16 def init(name, repo) if File.directory? name say("Directory #{name} already exists") if [:force] FileUtils.rm_r(name) elsif [:skip] if File.directory? File.join(name, 'config') and GitUtil.repo? File.join(name, 'config') return else FileUtils.rm_r(name) end else choice = ask('Are you sure you want do delete existing docroot? Type "yes" if you agree.') if choice == 'yes' FileUtils.rm_r(name) elsif Kernel::abort 'Exit' end end end puts "Init docroot directory #{name} and retrieve config from provided repo." Application.instance.init(name, repo, ) say('Complete!', :green) end |
#template(name = nil) ⇒ Object
101 102 103 104 105 106 107 |
# File 'lib/docman/cli.rb', line 101 def template(name = nil) current_dir_name = File.basename(Dir.pwd) get_to_root_dir name = current_dir_name if name.nil? Application.instance.template(name, ) say('Complete!', :green) end |