eventhub-command 0.6.10 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0bcb7db5976e5d3ddd64abcc0c262fd5314b59e9
4
- data.tar.gz: 4cf465ee87b690a790ab1b4e5bcfa869721ca422
3
+ metadata.gz: 0c7dbd01c57417a4d8ffdffd338f2fa1ad170d23
4
+ data.tar.gz: f582323a6905bae41cd7bba5b5bffe1f35b3533a
5
5
  SHA512:
6
- metadata.gz: cd77a2de01de709b108e1a9d86dbffec4c390fafd9d042cc48ec1a058734d7afcaec5ac5cb04c39590ef82f70f06493166fb7ced9f5c485a486f0289c31e7d4b
7
- data.tar.gz: c99c369dce891908400b05aea7f138ff11d38549ed9de7c91761b0631f453585fc19138edbd3b3ee72ae2607d1dd6a8fef5d652b508b991d92d857b8e4ba6fc9
6
+ metadata.gz: 52d5cabc1dd6546c835ec7fbef0c294b919135310bf933623048868f547e7a45ad650eeacc5ca04d49b00f326e86a7fc061e0791c2e5ac225c6a85f82a46e805
7
+ data.tar.gz: 1ee64c56a674128255197cdac3d2dbdd1969379a38825b27fdcb043f81c6b7724845837a8fbc9446cf1bdd3470a3f9717fe98792b02d9dbd3a67bcc6e5a227e9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 0.7.0 (2017-10-24)
2
+
3
+ * Fix: Generate ruby pocessor
4
+ * Edit: Harmonized subcommands
5
+ * Edit: Colorized output
6
+ * Edit: Newest GLI gem version
7
+ * New: More rspecs
8
+
1
9
  ## 0.6.8 (2016-11-05)
2
10
 
3
11
  Fix
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
+ [![Gem Version](https://badge.fury.io/rb/eventhub-command.svg)](https://badge.fury.io/rb/eventhub-command)
1
2
  [![Dependency Status](https://gemnasium.com/badges/github.com/thomis/eventhub-command.svg)](https://gemnasium.com/github.com/thomis/eventhub-command)
3
+ [![Build Status](https://travis-ci.org/thomis/eventhub-command.svg?branch=master)](https://travis-ci.org/thomis/eventhub-command)
2
4
 
3
5
  eventhub-command
4
6
  ================
data/bin/eh CHANGED
@@ -7,6 +7,7 @@ require 'bundler'
7
7
  include GLI::App
8
8
 
9
9
  program_desc 'Command line tools for EventHub'
10
+ sort_help :manually
10
11
 
11
12
  version Eh::VERSION
12
13
  config_file = File.expand_path(File.join('~', '.eh'))
@@ -17,19 +18,15 @@ else
17
18
  File.open(config_file, 'w') do |file|
18
19
  file.write(JSON.dump({}))
19
20
  end
20
- puts "No config File found. Created empty config file for you. You can run 'eh repository add/select' to manage repositories"
21
- exit
21
+ raise "No config File found. Created empty config file for you. You can run 'eh repository add/select' to manage repositories"
22
22
  end
23
23
 
24
-
25
24
  require 'eh-commands'
26
25
 
27
- # Use argument validation
28
- arguments :strict
29
-
30
26
  accept Array do |value|
31
27
  value.split(/,/).map(&:strip)
32
28
  end
33
29
 
34
- switch([:v, :verbose], :desc => "Show additional output.")
30
+ switch([:v, :verbose], :desc => "Show verbose output")
31
+
35
32
  exit run(ARGV)
@@ -15,15 +15,6 @@ class Deployer::ConfigDeployer < Deployer::BaseDeployer
15
15
 
16
16
  cmd = "rsync -r --exclude=.svn #{source} #{target}"
17
17
  executor.execute(cmd)
18
- # stage.hosts.each do |host|
19
- # hostname = host[:host]
20
- # source = cached_copy_dir('..', 'config', stage.name, hostname, '')
21
- # target = config_source_dir
22
-
23
- # # we use rsync to copy without .svn folders
24
- # cmd = "mkdir -p #{target} && rsync -r --exclude=.svn #{source} #{target}"
25
- # executor.execute_on(host, cmd)
26
- # end
27
18
  end
28
19
  end
29
20
  end
@@ -12,10 +12,8 @@ class Deployer::RubyDeployer < Deployer::BaseDeployer
12
12
  Deployer::Executor.new(stage, verbose: verbose?) do |executor|
13
13
  create_base_dirs(executor)
14
14
 
15
-
16
15
  update_cached_copy(executor)
17
16
 
18
-
19
17
  # fetch processor_names unless they have been passed as an argument to the initializer
20
18
  processor_names_to_deploy = resolve_processor_names(executor, options)
21
19
  processor_names_to_deploy.sort(& ruby_sorter).each do |processor_name|
data/lib/eh-commands.rb CHANGED
@@ -1,12 +1,12 @@
1
1
  # All commands are required here
2
2
  if Eh::Settings.current.repository
3
3
  require 'eh/commands/generate'
4
+ require 'eh/commands/package'
5
+ require 'eh/commands/deploy'
4
6
  require 'eh/commands/stage'
5
- require 'eh/commands/dump'
6
- require 'eh/commands/db'
7
7
  require 'eh/commands/proxy'
8
- require 'eh/commands/deploy'
9
- require 'eh/commands/package'
8
+ require 'eh/commands/dump'
9
+ require 'eh/commands/database'
10
10
  require 'eh/proxy/proxy'
11
11
  else
12
12
  # remove unused settings for this version
data/lib/eh.rb CHANGED
@@ -8,5 +8,6 @@ require 'eh/version'
8
8
  require 'eh/settings'
9
9
  require 'yaml'
10
10
 
11
+ require_relative 'helper'
11
12
  require_relative 'deployer'
12
13
  require_relative 'packager'
@@ -1,28 +1,27 @@
1
- desc 'dump and restore db. Attention: those commands run on the local machine, not remote.'
2
- command :db do |command|
1
+ desc 'Database commands (run on local machine)'
2
+ command :database do |database|
3
3
 
4
- command.switch([:v, :verbose], :desc => 'Show additional output.')
5
- command.flag([:user], default_value: 'event_hub_console', desc: 'DB User')
6
- command.flag([:db], default_value: 'event_hub_console', desc: 'DB name')
7
- command.flag([:file], desc: "Output Filename, last backup will be taken as default")
4
+ database.flag([:user], default_value: 'event_hub_console', desc: 'DB User')
5
+ database.flag([:db], default_value: 'event_hub_console', desc: 'DB name')
6
+ database.flag([:file], desc: "Output Filename, last backup will be taken as default")
8
7
 
9
- command.command :dump do |c|
10
- c.action do |global_options, options, args|
8
+ database.desc 'Dump database from defined stage'
9
+ database.command :dump do |dump|
10
+ dump.action do |global_options, options, args|
11
11
  base = Eh::Settings.current.db_backups_dir
12
12
  stamp = Time.now.strftime('%Y%m%d%H%M%S')
13
13
  target = options[:file] || "#{stamp}-console-dump.sql.compressed"
14
14
 
15
15
  cmd = "mkdir -p #{base} && cd #{base} && pg_dump -Fc -U#{options[:user]} #{options[:db]} -f#{target}"
16
- if options[:verbose]
17
- puts "will execute '#{cmd}'"
18
- end
16
+ puts "will execute '#{cmd}'" if global_options[:verbose]
19
17
  system cmd
20
- puts "Dumped DB to #{target}"
18
+ puts "Database has been dumped to #{target}".green
21
19
  end
22
20
  end
23
21
 
24
- command.command :restore do |c|
25
- c.action do |global_options, options, args|
22
+ database.desc 'Restore database to defined stage'
23
+ database.command :restore do |restore|
24
+ restore.action do |global_options, options, args|
26
25
  source = options[:file] || begin
27
26
  base = Eh::Settings.current.db_backups_dir
28
27
  pattern = File.join(base, '*')
@@ -36,19 +35,19 @@ command :db do |command|
36
35
  answer = $stdin.gets.chomp.downcase
37
36
  if answer == 'yes'
38
37
  cmd = "pg_restore -Fc -U #{options[:user]} -d #{options[:db]} #{source}"
39
- if options[:verbose]
40
- puts "will execute '#{cmd}'"
41
- end
38
+ puts "will execute '#{cmd}'" if global_options[:verbose]
42
39
  system cmd
40
+ puts "Database has been restored".green
43
41
  else
44
- puts "Abort."
42
+ puts "Aborted".green
45
43
  end
46
44
  end
47
45
  end
48
46
 
49
- command.command :cleanup_dumps do |c|
50
- c.flag([:keep], type: Integer, desc: "How many dumps to keep", default_value: 25)
51
- c.action do |global_options, options, args|
47
+ database.desc 'Cleanup dump files'
48
+ database.command :cleanup do |cleanup|
49
+ cleanup.flag([:keep], type: Integer, desc: "How many dumps to keep", default_value: 25)
50
+ cleanup.action do |global_options, options, args|
52
51
  keep = options[:keep]
53
52
  base = Eh::Settings.current.db_backups_dir
54
53
  pattern = File.join(base, '*')
@@ -56,12 +55,10 @@ command :db do |command|
56
55
  to_delete = files[keep..-1] || []
57
56
 
58
57
  to_delete.each do |file|
59
- if options[:verbose]
60
- puts "will delete #{file}"
61
- end
58
+ puts "will delete #{file}" if global_options[:verbose]
62
59
  system "rm #{file}"
63
60
  end
64
- puts "deleted #{to_delete.size} file(s)"
61
+ puts "Deleted #{to_delete.size} file(s)".green
65
62
  end
66
63
  end
67
64
 
@@ -1,15 +1,14 @@
1
- desc 'deployment commands'
2
- command :deploy do |c|
3
- c.flag([:stage], desc: 'stage', type: String, long_desc: 'Stage where processor is deployed to', default_value: Eh::Settings.current.default_stage)
4
- c.flag([:branch], desc: 'branch', type: String, long_desc: 'What branch to deploy. Only when deploy_via=scm', default_value: 'master')
5
- c.flag([:tag], desc: 'tag', type: String, long_desc: 'What tag to deploy. Only when deploy_via=scm', default_value: nil)
6
- c.switch([:v, :verbose], :desc => 'Show additional output.')
7
- c.flag([:deploy_via], desc: 'where to deploy from', type: String, long_desc: 'deploy via scm or scp. If you use scp then the working_dir is packaged and copied tot the servers', default_value: 'svn')
8
-
9
- c.desc 'deploy all'
10
- c.command :all do |c|
11
- c.action do |global_options, options, arguments|
12
- forward_arguments = arguments.join(' ')
1
+ desc 'Deployment commands'
2
+ command :deploy do |deploy|
3
+ deploy.flag([:stage], desc: 'stage', type: String, long_desc: 'Stage where processor is deployed to', default_value: Eh::Settings.current.default_stage)
4
+ deploy.flag([:branch], desc: 'branch', type: String, long_desc: 'What branch to deploy. Only when deploy_via=scm', default_value: 'master')
5
+ deploy.flag([:tag], desc: 'tag', type: String, long_desc: 'What tag to deploy. Only when deploy_via=scm', default_value: nil)
6
+ deploy.flag([:deploy_via], desc: 'where to deploy from', type: String, long_desc: 'deploy via scm or scp. If you use scp then the working_dir is packaged and copied tot the servers', default_value: 'svn')
7
+
8
+ deploy.desc 'Deploy all components'
9
+ deploy.command :all do |all|
10
+ all.action do |global_options, options, args|
11
+ forward_arguments = args.join(' ')
13
12
  deploy_config(options, forward_arguments)
14
13
  deploy_console(options, forward_arguments)
15
14
  deploy_go(options, forward_arguments)
@@ -18,26 +17,26 @@ command :deploy do |c|
18
17
  end
19
18
  end
20
19
 
21
- c.desc 'distribute the configs to the nodes'
22
- c.command :config do |c|
23
- c.action do |global_options, options, args|
20
+ deploy.desc 'Deploy configuration files'
21
+ deploy.command :config do |config|
22
+ config.action do |global_options, options, args|
24
23
  Deployer::ConfigDeployer.new(options).deploy!
25
24
  end
26
25
  end
27
26
 
28
- c.desc 'deploy the rails console app'
29
- c.command :console do |c|
30
- c.flag([:working_dir], desc: 'directory to execute commands in', type: String, default_value: '.')
27
+ deploy.desc 'Deploy rails console'
28
+ deploy.command :console do |console|
29
+ console.flag([:working_dir], desc: 'directory to execute commands in', type: String, default_value: '.')
31
30
 
32
- c.action do |global_options, options, args|
31
+ console.action do |global_options, options, args|
33
32
  Deployer::ConsoleDeployer.new(options).deploy!
34
33
  end
35
34
  end
36
35
 
37
- c.desc 'deploy a single channel adapter'
38
- c.arg_name '[channel_adapter[,other_channel_adapter,pattern*]]'
39
- c.command :mule do |c|
40
- c.action do |global_options, options, args|
36
+ deploy.desc 'Deploy channel adapter(s)'
37
+ deploy.arg_name '[NAME1[,NAME2,PATTERN*]]'
38
+ deploy.command :mule do |mule|
39
+ mule.action do |global_options, options, args|
41
40
  if args[0]
42
41
  adapter_names = args[0].split(',').map(&:strip)
43
42
  else
@@ -47,10 +46,10 @@ command :deploy do |c|
47
46
  end
48
47
  end
49
48
 
50
- c.desc 'deploy a single ruby processor'
51
- c.arg_name '[processor_name,[other_processor_name,pattern*]]'
52
- c.command :ruby do |c|
53
- c.action do |global_options, options, args|
49
+ deploy.desc 'Deploy ruby processor(s)'
50
+ deploy.arg_name '[NAME1[,NAME2,PATTERN*]]'
51
+ deploy.command :ruby do |ruby|
52
+ ruby.action do |global_options, options, args|
54
53
  if args[0]
55
54
  processor_names = args[0].split(',').map(&:strip)
56
55
  else
@@ -60,9 +59,9 @@ command :deploy do |c|
60
59
  end
61
60
  end
62
61
 
63
- c.desc 'deploy a single go processor'
64
- c.arg_name '[processor_name,[other_processor_name,pattern*]]'
65
- c.command :go do |go|
62
+ deploy.desc 'Deploy go processor(s)'
63
+ deploy.arg_name '[NAME1[,NAME2,PATTERN*]]'
64
+ deploy.command :go do |go|
66
65
  go.action do |global_options, options, args|
67
66
  if args[0]
68
67
  processor_names = args[0].split(',').map(&:strip)
@@ -1,10 +1,10 @@
1
- desc "manage repositories"
1
+ desc "Creating a dump from an eventhub environment with database, logfiles, folders"
2
2
 
3
3
  command :dump do |command|
4
4
  command.desc "Create a backup"
5
5
  command.flag([:stage], desc: 'stage', type: String, long_desc: 'Stage where processor is deployed to', default_value: Eh::Settings.current.default_stage)
6
- command.switch([:v, :verbose], :desc => 'Show additional output.')
7
6
 
7
+ command.desc('Download dumped database')
8
8
  command.command :download do |command|
9
9
 
10
10
  command.action do |global_options, options, args|
@@ -21,6 +21,7 @@ command :dump do |command|
21
21
  end
22
22
  end
23
23
 
24
+ command.desc('Create dump file from database')
24
25
  command.command :create do |command|
25
26
 
26
27
  command.action do |global_options, options, args|
@@ -35,14 +36,12 @@ command :dump do |command|
35
36
  cmds << "cd #{dir} && zip -r #{zip_target} ."
36
37
  cmds << "rm -rf #{dir}"
37
38
 
38
-
39
- Deployer::Executor.new(stage(options).single_host_stage, verbose: options[:verbose]) do |executor|
39
+ Deployer::Executor.new(stage(options).single_host_stage, verbose: global_options[:verbose]) do |executor|
40
40
  cmds.each do |cmd|
41
41
  executor.execute(cmd)
42
42
  end
43
43
  end
44
44
 
45
-
46
45
  puts "Created an dump in #{zip_target}. Use #{stamp.green} as identifier for eh dump download."
47
46
  end
48
47
  end
@@ -1,14 +1,16 @@
1
- desc 'Generates a template for a processor'
2
- arg_name 'module_name processor_name'
1
+ desc 'Generate template for a new processor'
3
2
  command :generate do |c|
4
- c.command :processor do |c|
3
+
4
+ c.arg_name 'MODULE_NAME PROCESSOR_NAME'
5
+ c.desc "Generate ruby based processor"
6
+ c.command :ruby do |c|
5
7
  c.action do |global_options, options, args|
6
8
  require 'active_support/core_ext/string/inflections'
7
9
  require 'fileutils'
8
10
  require 'erb'
9
11
 
10
12
  if args.size != 2
11
- puts "Needs exactly 2 arguments: eh generate_processor ModuleName ProcessorName"
13
+ puts "Needs exactly 2 arguments: eh generate processor MODULE NAME"
12
14
  exit -1
13
15
  end
14
16
 
@@ -17,7 +19,7 @@ command :generate do |c|
17
19
  underscored_processor_module_name = processor_module_name.underscore
18
20
  underscored_processor_class_name = processor_class_name.underscore
19
21
 
20
- destination_dir = Eh::Settings.current.processors_src_dir
22
+ destination_dir = Eh::Settings.current.ruby_processors_src_dir
21
23
  destination_dir = File.join(destination_dir, "#{underscored_processor_module_name}.#{underscored_processor_class_name}")
22
24
 
23
25
  if Dir.exists? destination_dir
@@ -1,37 +1,36 @@
1
- desc 'package commands'
2
- command :package do |c|
3
- c.flag([:s, :source], :desc => "Source directory to read processors from.")
4
- c.flag([:d, :destination], :desc => "Destination directory to place created zip files.")
1
+ desc 'Package commands'
2
+ command :package do |package|
3
+ package.flag([:s, :source], :desc => "Source directory to read processors from.")
4
+ package.flag([:d, :destination], :desc => "Destination directory to place created zip files.")
5
+ package.flag([:x, :exclude], arg_name: 'NAME1,NAME2,PATTERN*', desc: "Exclude components with NAME1,NAME2,PATTERN*", type: String)
5
6
 
6
- c.desc 'Packages ruby processors to zip files'
7
- c.arg_name '[processor_name,[other_processor_name,pattern*]]'
8
- c.command :ruby do |ruby|
9
- ruby.flag([:i, :include], :desc => "Include processors by name format: [processor_name,[other_processor_name,pattern*]]", :type => String, :long_desc => "You can specify multiple processors by providing a comma-separated list as well as pattern using '*'")
10
- ruby.flag([:x, :exclude], :desc => "Exclude processors by name format: [processor_name,[other_processor_name,pattern*]]", :type => String, :long_desc => "You can specify multiple processors by providing a comma-separated list as well as pattern using '*'")
7
+ package.desc 'Packages ruby processors to zip files'
8
+ package.arg_name '[NAME1,[NAME2,PATTERN*]]'
9
+ package.command :ruby do |ruby|
11
10
 
12
11
  ruby.action do |global_options, options, args|
13
12
  options['s'] ||= Eh::Settings.current.ruby_processors_src_dir
14
13
  options['d'] ||= Eh::Settings.current.ruby_release_dir
15
14
  source_dir = options.fetch('s')
16
15
  destination_dir = options.fetch('d')
17
- include_pattern = options['i'] || args[0]
16
+ include_pattern = args[0]
18
17
  exclude_pattern = options['x']
19
18
  packager = Packager::Ruby.new(source_dir, destination_dir, include_pattern, exclude_pattern)
20
19
  packager.package
21
20
  end
22
21
  end
23
22
 
24
- c.desc 'Packages go processors to zip files'
25
- c.command :go do |go|
26
-
27
- go.flag([:p, :platform], :desc => "Define target platform [linux, osx, window]")
23
+ package.desc 'Packages go processors to zip files'
24
+ package.arg_name '[NAME1,[NAME2,PATTERN*]]'
25
+ package.command :go do |go|
26
+ go.flag([:p, :platform], arg_name: 'PLATFORM', desc: 'Target platform', must_match: ['linux', 'darwin', 'windows'], default_value: 'linux')
28
27
 
29
28
  go.action do |global_options, options, args|
30
29
  options['s'] ||= Eh::Settings.current.go_processors_src_dir
31
30
  options['d'] ||= Eh::Settings.current.go_release_dir
32
31
  source_dir = options.fetch('s')
33
32
  destination_dir = options.fetch('d')
34
- include_pattern = options['i'] || args[0]
33
+ include_pattern = args[0]
35
34
  exclude_pattern = options['x']
36
35
  platform = options['p'] || 'linux'
37
36
  packager = Packager::Go.new(source_dir, destination_dir, include_pattern, exclude_pattern, platform)
@@ -40,11 +39,14 @@ command :package do |c|
40
39
 
41
40
  end
42
41
 
43
- c.desc 'Packages rails console app to zip file'
44
- c.command :rails do |rails|
42
+ package.desc 'Packages rails console app to zip file'
43
+ package.command :rails do |rails|
45
44
  rails.action do |global_options, options, args|
46
45
  options['s'] ||= Eh::Settings.current.rails_src_dir
47
46
  options['d'] ||= Eh::Settings.current.rails_release_dir
47
+
48
+ raise 'Flag [-x, --exclude] is currently not supported with rails subcommand' if options[:exclude]
49
+
48
50
  source_dir = options.fetch('s')
49
51
  destination_dir = options.fetch('d')
50
52
 
@@ -1,50 +1,54 @@
1
- desc 'enable/disable proxy'
1
+ desc 'Manage proxies'
2
+ command :proxy do |proxy|
2
3
 
3
- command :proxy do |c|
4
+ proxy.switch([:v, :verbose], :desc => 'Show additional output.')
5
+ proxy.flag([:stage], desc: 'stage', type: String, long_desc: 'Stage where proxy is', default_value: Eh::Settings.current.default_stage)
4
6
 
5
- c.switch([:v, :verbose], :desc => 'Show additional output.')
6
- c.flag([:stage], desc: 'stage', type: String, long_desc: 'Stage where proxy is', default_value: Eh::Settings.current.default_stage)
7
-
8
- c.command :off do |c|
9
-
10
- c.action do |global_options, options, arguments|
11
- Eh::Proxy::Proxy.new(options[:stage], options[:verbose]).unset
7
+ proxy.desc 'List defined proxies'
8
+ proxy.command :list do |list|
9
+ list.action do |global_options, options, arguments|
10
+ Eh::Proxy::Proxy.new(options[:stage], options[:verbose]).list
12
11
  end
13
12
  end
14
13
 
15
- c.command :on do |c|
16
- c.arg_name 'name'
17
- c.action do |global_options, options, arguments|
18
- Eh::Proxy::Proxy.new(options[:stage], options[:verbose]).set(arguments[0])
14
+ proxy.desc 'Select proxy by NAME'
15
+ proxy.arg_name 'NAME'
16
+ proxy.command :select do |select|
17
+ select.action do |global_options, options, arguments|
18
+ Eh::Proxy::Proxy.new(options[:stage], options[:verbose]).select(arguments[0])
19
19
  end
20
-
21
20
  end
22
21
 
23
- c.command :list do |c|
24
- c.action do |global_options, options, arguments|
25
- Eh::Proxy::Proxy.new(options[:stage], options[:verbose]).list
22
+ proxy.desc 'Enable proxy default or by NAME'
23
+ proxy.arg_name 'NAME'
24
+ proxy.command :on do |on|
25
+ on.action do |global_options, options, arguments|
26
+ Eh::Proxy::Proxy.new(options[:stage], options[:verbose]).set(arguments[0])
26
27
  end
27
28
  end
28
29
 
29
- c.arg_name 'name'
30
- c.command :remove do |c|
31
- c.action do |global_options, options, arguments|
32
- Eh::Proxy::Proxy.new(options[:stage], options[:verbose]).remove(arguments[0])
30
+ proxy.desc 'Disable default proxy'
31
+ proxy.command :off do |off|
32
+ off.action do |global_options, options, arguments|
33
+ Eh::Proxy::Proxy.new(options[:stage], options[:verbose]).unset
33
34
  end
34
35
  end
35
36
 
36
- c.arg_name 'name'
37
- c.arg_name 'proxy'
38
- c.command :add do |c|
39
- c.action do |global, options, arguments|
37
+ proxy.desc 'Add new proxy by NAME and PROXY_URL'
38
+ proxy.arg_name 'NAME PROXY_URL'
39
+ proxy.command :add do |add|
40
+ add.action do |global, options, arguments|
40
41
  Eh::Proxy::Proxy.new(options[:stage], options[:verbose]).add(arguments[0], arguments[1])
41
42
  end
42
43
  end
43
44
 
44
- c.arg_name 'name'
45
- c.command :select do |c|
46
- c.action do |global_options, options, arguments|
47
- Eh::Proxy::Proxy.new(options[:stage], options[:verbose]).select(arguments[0])
45
+ proxy.desc "Remove by NAME"
46
+ proxy.arg_name 'NAME'
47
+ proxy.command :remove do |remove|
48
+ remove.action do |global_options, options, arguments|
49
+ Eh::Proxy::Proxy.new(options[:stage], options[:verbose]).remove(arguments[0])
48
50
  end
49
51
  end
52
+
53
+ proxy.default_command :list
50
54
  end
@@ -1,39 +1,45 @@
1
- desc "manage repositories"
1
+ desc "Manage repositories"
2
2
 
3
3
  command :repository do |command|
4
4
  command.desc "Lists all avaiable repositories"
5
5
  command.command :list do |command|
6
6
  command.action do |global_options,options,args|
7
7
 
8
+ puts "Defined Repositories [#{Eh::Settings.current.data['repositories'].size}]"
8
9
  Eh::Settings.current.repositories.each_with_index do |repository, index|
9
10
  if repository.current?
10
- puts "#{index + 1}: #{repository.url} (current)"
11
+ puts " #{index+1}. #{repository.url} (current)".green
11
12
  else
12
- puts "#{index + 1}: #{repository.url}"
13
+ puts " #{index+1}. #{repository.url}"
13
14
  end
14
15
  end
15
16
  end
16
17
  end
17
18
 
18
- command.desc "selects a repository: eh repository select INDEX"
19
+ command.desc "Selects a repository by INDEX"
20
+ command.arg_name 'INDEX'
19
21
  command.command :select do |command|
20
22
  command.action do |global_options,options,args|
21
23
  if Eh::Settings.current.repositories.length == 0
22
24
  raise "No repository configured so far"
23
25
  end
24
26
  if args.length != 1
25
- raise "Need exactly 1 arguments: index"
27
+ raise "Needs mandatory INDEX argument"
26
28
  end
27
29
  selected = args[0].to_i
30
+ if selected > Eh::Settings.current.data['repositories'].size
31
+ raise "Argument INDEX is out of range"
32
+ end
28
33
  Eh::Settings.current.data['repositories'].each_with_index do |repository, index|
29
34
  repository['current'] = (index + 1) == selected
30
35
  end
31
- puts "Selected #{Eh::Settings.current.repository.url}"
32
36
  Eh::Settings.current.write
37
+ puts "Repository selected: #{Eh::Settings.current.repository.url}".green
33
38
  end
34
39
  end
35
40
 
36
- command.desc 'add a repository to the config: eh repository add URL DIR USERNAME PASSWORD'
41
+ command.desc 'Add a repository with URL DIR USERNAME PASSWORD'
42
+ command.arg_name 'URL DIR USERNAME PASSWORD'
37
43
  command.command :add do |command|
38
44
  command.action do |global_options, options, args|
39
45
  if args.length != 4
@@ -46,7 +52,7 @@ command :repository do |command|
46
52
  repository['url'] == args[0]
47
53
  end
48
54
  if exists
49
- raise "Already configured repository for '#{args[0]}'"
55
+ raise "Already configured repository [#{args[0]}]"
50
56
  end
51
57
 
52
58
  Eh::Settings.current.data['repositories'] << {
@@ -57,25 +63,32 @@ command :repository do |command|
57
63
  'current' => (Eh::Settings.current.data['repositories'].length == 0)
58
64
  }
59
65
  Eh::Settings.current.write
66
+
67
+ puts "New Repository [#{args[0]}] has beed added. Total Repositories: #{Eh::Settings.current.data['repositories'].size}".green
60
68
  end
61
69
  end
62
70
 
63
71
 
64
- command.desc 'remove a repository from the config: eh repository remove INDEX'
72
+ command.desc 'Remove a repository by INDEX'
73
+ command.arg_name 'INDEX'
65
74
  command.command :remove do |command|
66
75
  command.action do |global_options, options, args|
67
76
 
68
77
  if args.length != 1
69
- raise "Need exactly 1 arguments: index"
78
+ raise "Needs mandatory INDEX argument"
70
79
  end
71
80
  selected = args[0].to_i
72
81
 
73
82
  if Eh::Settings.current.repositories[selected - 1].nil?
74
- raise "No repository with index #{selected}"
83
+ raise "No repository with index [selected]"
75
84
  end
76
85
 
77
86
  Eh::Settings.current.data['repositories'].delete_at(selected - 1)
78
87
  Eh::Settings.current.write
88
+
89
+ puts "Repository has been removed. Total Repositories: #{Eh::Settings.current.data['repositories'].size}".green
79
90
  end
80
91
  end
92
+
93
+ command.default_command :list
81
94
  end
@@ -1,25 +1,39 @@
1
- desc 'manage stages'
1
+ desc 'Manage stages'
2
2
  command :stage do |command|
3
-
4
- command.switch([:v, :verbose], :desc => 'Show additional output.')
5
- command.command :list do |c|
6
- c.action do |global_options, options, args|
3
+ command.desc 'List defined stages'
4
+ command.command :list do |list|
5
+ list.action do |global_options, options, args|
7
6
  dir = Eh::Settings.current.stages_dir
8
- puts "Checking in #{dir}".green if options[:verbose]
9
- puts "Available stages are:".blue
7
+ puts "Checking in #{dir}".yellow if global_options[:verbose]
8
+ puts "Available Stages"
10
9
  Dir.glob(File.join(dir, '*.yml')) do |name|
11
10
  stage_name = File.basename(name, '.*')
12
- default = '(default)' if Eh::Settings.current.default_stage == stage_name
13
- puts "#{stage_name} #{default}".light_blue
11
+ is_default = Eh::Settings.current.default_stage == stage_name
12
+ puts " - #{stage_name} #{is_default ? '(default)' : nil}".send(is_default ? :green : :white)
14
13
  end
15
14
  end
16
15
  end
17
- command.command :select_default do |c|
18
- c.action do |global_options, options, args|
19
- stage = args[0]
20
- Eh::Settings.current.data['default_stage'] = stage
16
+
17
+ command.desc 'Select default stage'
18
+ command.arg_name 'NAME'
19
+ command.command :select do |default|
20
+ default.action do |global_options, options, args|
21
+ new_stage = args[0]
22
+
23
+ if args.size != 1
24
+ raise "Needs a stage NAME to select"
25
+ end
26
+
27
+ # check if new_stage.yml exist in stages folder
28
+ unless File.exist?(File.join(Eh::Settings.current.stages_dir, "#{new_stage}.yml"))
29
+ raise "Stage [#{new_stage}] is not defined yet"
30
+ end
31
+
32
+ Eh::Settings.current.data['default_stage'] = new_stage
21
33
  Eh::Settings.current.write
22
- puts "Set stage default to '#{stage}'"
34
+ puts "Default stage selected: #{new_stage}".green
23
35
  end
24
36
  end
37
+
38
+ command.default_command :list
25
39
  end
@@ -28,21 +28,23 @@ module Eh
28
28
  end
29
29
 
30
30
  def remove(name)
31
+ raise "Needs a proxy NAME to remove" if name.nil?
31
32
  proxy = find_proxy_by_name(name)
32
33
  if proxy.nil?
33
- raise "No proxy with name #{name}"
34
+ raise "No proxy with given name [#{name}]"
34
35
  end
35
36
 
36
37
  Eh::Settings.current.data['proxies'].reject! { |json| json['name'] == name}
37
38
  Eh::Settings.current.write
39
+ puts "Proxy [#{name}] has been removed".green
38
40
  end
39
41
 
40
42
  def add(name, url)
41
43
  if name.nil? || url.nil?
42
- raise "Please provide name and url"
44
+ raise "Please provide NAME and PROXY_URL"
43
45
  end
44
46
  if find_proxy_by_name(name) || find_proxy_by_url(url)
45
- raise "Already configured proxy for '#{name} -> #{url}'"
47
+ raise "Already configured proxy for [#{name} -> #{url}]"
46
48
  end
47
49
 
48
50
  Eh::Settings.current.data['proxies'] << {
@@ -51,23 +53,27 @@ module Eh
51
53
  'default' => (Eh::Settings.current.proxies.length == 0)
52
54
  }
53
55
  Eh::Settings.current.write
56
+ puts "Proxy [#{name}] has been added".green
54
57
  end
55
58
 
56
59
  def select(name)
60
+ raise "Needs a proxy NAME to select" if name.nil?
57
61
  proxy = find_proxy_by_name(name)
58
62
  if proxy.nil?
59
- raise "No proxy found with name #{name}"
63
+ raise "No proxy found with given name [#{name}]"
60
64
  end
61
65
 
62
66
  Eh::Settings.current.data['proxies'].each do |json|
63
67
  json['default'] = (json['name'] == name)
64
68
  end
65
69
  Eh::Settings.current.write
70
+ puts "Proxy [#{name}] has been selected".green
66
71
  end
67
72
 
68
73
  def list
74
+ puts "Defined Proxies"
69
75
  Eh::Settings.current.proxies.each do |proxy|
70
- puts proxy.label
76
+ puts proxy.label.send( proxy.label =~ /\(default\)/ ? :green : :white )
71
77
  end
72
78
  end
73
79
 
@@ -31,7 +31,7 @@ module Eh::Proxy::Settings
31
31
  end
32
32
 
33
33
  def set_command(value)
34
- "git config --global http.proxy http://#{value} ; git config --global https.proxy https://#{value}"
34
+ "git config --global http.proxy http://#{trim_url(value)} ; git config --global https.proxy https://#{trim_url(value)}"
35
35
  end
36
36
  end
37
37
  end
@@ -26,7 +26,7 @@ module Eh::Proxy::Settings
26
26
  end
27
27
 
28
28
  def set(value)
29
- uri = URI.parse("http://#{value}")
29
+ uri = URI.parse("http://#{trim_url(value)}")
30
30
 
31
31
  Deployer::Executor.new(stage, verbose: verbose?) do |executor|
32
32
  executor.download("~/.subversion/servers", temporary_config_file)
data/lib/eh/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eh
2
- VERSION = '0.6.10'
2
+ VERSION = '0.7.0'
3
3
  end
data/lib/helper.rb ADDED
@@ -0,0 +1,13 @@
1
+ # have a custom error handling
2
+ # have no "error:"-prefix and all text is red
3
+ if self.respond_to?(:on_error) # to exclude it in rspecs
4
+ on_error do |exception|
5
+ $stderr.puts exception.to_s.red
6
+ false # skip GLI's error handling
7
+ end
8
+ end
9
+
10
+ # helper method to trim url
11
+ def trim_url(str)
12
+ str.sub(%r{^https?:(//|\\\\)}i, '')
13
+ end
data/lib/packager/go.rb CHANGED
@@ -14,7 +14,6 @@ class Packager::Go
14
14
  assert_at_least_one_processor!
15
15
  validate_platforms!
16
16
  create_destination_dir
17
- #copy_deployment_management_files
18
17
  build_processors
19
18
  package_processors
20
19
  end
@@ -41,7 +40,7 @@ class Packager::Go
41
40
  processor_names.each do |processor_name|
42
41
  package_processor(processor_name)
43
42
  end
44
- puts "Done packaging #{processor_names.size} processors"
43
+ puts "Done packaging #{processor_names.size} processors".green
45
44
  end
46
45
 
47
46
  def package_processor(processor_name)
@@ -85,12 +84,6 @@ class Packager::Go
85
84
  File.join(destination_dir, "#{processor_name}.zip")
86
85
  end
87
86
 
88
- def copy_deployment_management_files
89
- Eh::Settings.current.deployment_management_files.each do |file|
90
- FileUtils.cp(file, destination_dir)
91
- end
92
- end
93
-
94
87
  def assert_at_least_one_processor!
95
88
  if processor_names.empty?
96
89
  raise "There are no processor names. Either your -s directory is empty or you specified a strange combination of include and exclude pattern."
@@ -42,19 +42,3 @@ class Packager::Rails
42
42
  FileUtils.rm destination_file_name(dir), force: true
43
43
  end
44
44
  end
45
-
46
-
47
- # files_and_dirs =
48
- # source = options[:source]
49
- #
50
- # dirs = Dir.glob("#{source}")
51
- # dirs.each do |dir|
52
- # app = File.basename(dir)
53
- # destination = File.join(options[:d], "#{app}.zip")
54
- # included = files_and_dirs.map do |s|
55
- # File.join(app, s)
56
- # end.join(' ')
57
- # cmd = "cd #{File.join(dir, '..')} && zip -r #{destination} #{included}"
58
- # ret = system cmd
59
- # puts "Packaged #{app}: #{ret}"
60
- # end
data/lib/packager/ruby.rb CHANGED
@@ -22,7 +22,7 @@ class Packager::Ruby
22
22
  processor_names.each do |processor_name|
23
23
  package_processor(processor_name)
24
24
  end
25
- puts "Done packaging #{processor_names.size} processors"
25
+ puts "Done packaging #{processor_names.size} processors".green
26
26
  end
27
27
 
28
28
  def package_processor(processor_name)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventhub-command
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.10
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pascal Betz
@@ -9,148 +9,134 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-02-07 00:00:00.000000000 Z
12
+ date: 2017-10-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: rake
15
+ name: bundler
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '12.0'
20
+ version: 1.15.4
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '12.0'
27
+ version: 1.15.4
28
28
  - !ruby/object:Gem::Dependency
29
- name: rdoc
29
+ name: rake
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '5.0'
34
+ version: '12.0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '5.0'
41
+ version: '12.0'
42
42
  - !ruby/object:Gem::Dependency
43
- name: aruba
43
+ name: rspec
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '0.5'
48
+ version: '3.7'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '0.5'
55
+ version: '3.7'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: gli
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - '='
61
61
  - !ruby/object:Gem::Version
62
- version: 2.12.0
62
+ version: 2.17.0
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - '='
68
68
  - !ruby/object:Gem::Version
69
- version: 2.12.0
69
+ version: 2.17.0
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rubyzip
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: '1.0'
77
- type: :runtime
78
- prerelease: false
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - "~>"
82
- - !ruby/object:Gem::Version
83
- version: '1.0'
84
- - !ruby/object:Gem::Dependency
85
- name: activesupport
86
- requirement: !ruby/object:Gem::Requirement
87
- requirements:
88
- - - "~>"
89
- - !ruby/object:Gem::Version
90
- version: '5.0'
76
+ version: 1.2.1
91
77
  type: :runtime
92
78
  prerelease: false
93
79
  version_requirements: !ruby/object:Gem::Requirement
94
80
  requirements:
95
81
  - - "~>"
96
82
  - !ruby/object:Gem::Version
97
- version: '5.0'
83
+ version: 1.2.1
98
84
  - !ruby/object:Gem::Dependency
99
85
  name: net-ssh
100
86
  requirement: !ruby/object:Gem::Requirement
101
87
  requirements:
102
88
  - - "~>"
103
89
  - !ruby/object:Gem::Version
104
- version: '4.0'
90
+ version: 4.2.0
105
91
  type: :runtime
106
92
  prerelease: false
107
93
  version_requirements: !ruby/object:Gem::Requirement
108
94
  requirements:
109
95
  - - "~>"
110
96
  - !ruby/object:Gem::Version
111
- version: '4.0'
97
+ version: 4.2.0
112
98
  - !ruby/object:Gem::Dependency
113
99
  name: colorize
114
100
  requirement: !ruby/object:Gem::Requirement
115
101
  requirements:
116
102
  - - "~>"
117
103
  - !ruby/object:Gem::Version
118
- version: '0.7'
104
+ version: 0.8.1
119
105
  type: :runtime
120
106
  prerelease: false
121
107
  version_requirements: !ruby/object:Gem::Requirement
122
108
  requirements:
123
109
  - - "~>"
124
110
  - !ruby/object:Gem::Version
125
- version: '0.7'
111
+ version: 0.8.1
126
112
  - !ruby/object:Gem::Dependency
127
113
  name: highline
128
114
  requirement: !ruby/object:Gem::Requirement
129
115
  requirements:
130
116
  - - "~>"
131
117
  - !ruby/object:Gem::Version
132
- version: '1.7'
118
+ version: 1.7.8
133
119
  type: :runtime
134
120
  prerelease: false
135
121
  version_requirements: !ruby/object:Gem::Requirement
136
122
  requirements:
137
123
  - - "~>"
138
124
  - !ruby/object:Gem::Version
139
- version: '1.7'
125
+ version: 1.7.8
140
126
  - !ruby/object:Gem::Dependency
141
127
  name: parseconfig
142
128
  requirement: !ruby/object:Gem::Requirement
143
129
  requirements:
144
130
  - - "~>"
145
131
  - !ruby/object:Gem::Version
146
- version: '1.0'
132
+ version: 1.0.8
147
133
  type: :runtime
148
134
  prerelease: false
149
135
  version_requirements: !ruby/object:Gem::Requirement
150
136
  requirements:
151
137
  - - "~>"
152
138
  - !ruby/object:Gem::Version
153
- version: '1.0'
139
+ version: 1.0.8
154
140
  description: Event Hub Command Line Tool which supports you with various Event Hub
155
141
  related administrative development features.
156
142
  email:
@@ -176,7 +162,7 @@ files:
176
162
  - lib/deployer/stage.rb
177
163
  - lib/eh-commands.rb
178
164
  - lib/eh.rb
179
- - lib/eh/commands/db.rb
165
+ - lib/eh/commands/database.rb
180
166
  - lib/eh/commands/deploy.rb
181
167
  - lib/eh/commands/dump.rb
182
168
  - lib/eh/commands/generate.rb
@@ -190,6 +176,7 @@ files:
190
176
  - lib/eh/proxy/settings/svn.rb
191
177
  - lib/eh/settings.rb
192
178
  - lib/eh/version.rb
179
+ - lib/helper.rb
193
180
  - lib/packager.rb
194
181
  - lib/packager/go.rb
195
182
  - lib/packager/rails.rb
@@ -214,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
201
  version: '0'
215
202
  requirements: []
216
203
  rubyforge_project:
217
- rubygems_version: 2.5.1
204
+ rubygems_version: 2.6.12
218
205
  signing_key:
219
206
  specification_version: 4
220
207
  summary: Event Hub Command Line Tool