es-cli 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0ffa10d0d76a679f8c9936085c6e91e1a9b182b5
4
+ data.tar.gz: b824092fab85f5482bad7496e063b5e466589ea1
5
+ SHA512:
6
+ metadata.gz: 2979e1ec3e566146654ae7af1e95878a2266ad6da27a2fa867860ffdb426020da8529f2444d26613618b1bee07fd082fff6852593071cd6f0ad1fd613037c6a5
7
+ data.tar.gz: cba0176492583eb2e042817ca3060fd303085b7591dde0bf1230edbceac54dc18c94c8903463899c8df855642c5c96899126b5cbbe498b007a1ac465d9746e93
@@ -0,0 +1,46 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /vendor/bundle
26
+ /lib/bundler/man/
27
+
28
+ # for a library or gem, you might want to ignore these files since the code is
29
+ # intended to run in multiple environments; otherwise, check them in:
30
+ # Gemfile.lock
31
+ # .ruby-version
32
+ # .ruby-gemset
33
+
34
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
+ .rvmrc
36
+
37
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion
38
+
39
+ *.iml
40
+
41
+ ## Directory-based project format:
42
+ .idea/
43
+
44
+ ## File-based project format:
45
+ *.ipr
46
+ *.iws
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
@@ -0,0 +1,63 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ es-cli (0.0.1)
5
+ awesome_print (~> 1.6)
6
+ elasticsearch (~> 1.0)
7
+ gli (= 2.13.0)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ aruba (0.6.2)
13
+ childprocess (>= 0.3.6)
14
+ cucumber (>= 1.1.1)
15
+ rspec-expectations (>= 2.7.0)
16
+ awesome_print (1.6.1)
17
+ builder (3.2.2)
18
+ childprocess (0.5.6)
19
+ ffi (~> 1.0, >= 1.0.11)
20
+ cucumber (2.0.0)
21
+ builder (>= 2.1.2)
22
+ cucumber-core (~> 1.1.3)
23
+ diff-lcs (>= 1.1.3)
24
+ gherkin (~> 2.12)
25
+ multi_json (>= 1.7.5, < 2.0)
26
+ multi_test (>= 0.1.2)
27
+ cucumber-core (1.1.3)
28
+ gherkin (~> 2.12.0)
29
+ diff-lcs (1.2.5)
30
+ elasticsearch (1.0.8)
31
+ elasticsearch-api (= 1.0.7)
32
+ elasticsearch-transport (= 1.0.7)
33
+ elasticsearch-api (1.0.7)
34
+ multi_json
35
+ elasticsearch-transport (1.0.7)
36
+ faraday
37
+ multi_json
38
+ faraday (0.9.1)
39
+ multipart-post (>= 1.2, < 3)
40
+ ffi (1.9.8)
41
+ gherkin (2.12.2)
42
+ multi_json (~> 1.3)
43
+ gli (2.13.0)
44
+ json (1.8.2)
45
+ multi_json (1.11.0)
46
+ multi_test (0.1.2)
47
+ multipart-post (2.0.0)
48
+ rake (10.4.2)
49
+ rdoc (4.2.0)
50
+ json (~> 1.4)
51
+ rspec-expectations (3.2.1)
52
+ diff-lcs (>= 1.2.0, < 2.0)
53
+ rspec-support (~> 3.2.0)
54
+ rspec-support (3.2.2)
55
+
56
+ PLATFORMS
57
+ ruby
58
+
59
+ DEPENDENCIES
60
+ aruba
61
+ es-cli!
62
+ rake
63
+ rdoc
@@ -0,0 +1,90 @@
1
+ ## es-cli
2
+
3
+ A command line interface for elasticsearch
4
+
5
+ COMMANDS
6
+ cluster health [profile] - Print the cluster health
7
+ c h [profile] - Same as cluster health
8
+
9
+
10
+ ### Installation
11
+
12
+ `gem install es-cli`
13
+
14
+ #### Optional - add an alias to your `.bash_profile`
15
+
16
+ `alias es='es-cli'`
17
+
18
+
19
+ ### Configuration File for Profiles
20
+
21
+ Example `.es-cli.yml` which goes in your home directory.
22
+
23
+ <pre>
24
+ ---
25
+ # The default profile that will activate by default when no parameter is given
26
+ :default:
27
+ :es_url: http://localhost:9200
28
+ # Add `stage` to end of command to use stage profile
29
+ :stage:
30
+ :es_url: http://localhost:9300
31
+
32
+ </pre>
33
+
34
+ Run a command with a profile activated:
35
+
36
+ `es-cli -p stage cluster health`
37
+
38
+ ### Example Commands
39
+
40
+ Example `cluster health` command:
41
+
42
+
43
+ $es-cli c h
44
+ {
45
+ "cluster_name" => "elasticsearch",
46
+ "status" => "green",
47
+ "timed_out" => false,
48
+ "number_of_nodes" => 1,
49
+ "number_of_data_nodes" => 1,
50
+ "active_primary_shards" => 0,
51
+ "active_shards" => 0,
52
+ "relocating_shards" => 0,
53
+ "initializing_shards" => 0,
54
+ "unassigned_shards" => 0,
55
+ "number_of_pending_tasks" => 0
56
+ }
57
+
58
+ Example `node stats` command:
59
+
60
+
61
+ $es-cli node stats --m transport
62
+ {
63
+ "cluster_name" => "elasticsearch",
64
+ "nodes" => {
65
+ "E4MVBLgxRoqvETui00Y3GA" => {
66
+ "timestamp" => 1431057233915,
67
+ "name" => "Mindworm",
68
+ "transport_address" => "inet[/10.0.0.10:9300]",
69
+ "host" => "Brandons-MacBook-Pro.local",
70
+ "ip" => [
71
+ [0] "inet[/10.0.0.10:9300]",
72
+ [1] "NONE"
73
+ ],
74
+ "transport" => {
75
+ "server_open" => 13,
76
+ "rx_count" => 6,
77
+ "rx_size_in_bytes" => 1584,
78
+ "tx_count" => 6,
79
+ "tx_size_in_bytes" => 1584
80
+ }
81
+ }
82
+ }
83
+ }
84
+
85
+
86
+ ### TODO
87
+ - add more commands
88
+ - add more options
89
+ - add global settings
90
+
@@ -0,0 +1,14 @@
1
+ = es-cli
2
+
3
+ Describe your project here
4
+
5
+ :include:es-cli.rdoc
6
+
7
+
8
+ Example .es-cli.yml which goes in your home directory.
9
+ ---
10
+ # The default profile that will activate
11
+ :default:
12
+ :es_url: http://localhost:9200
13
+ :stage:
14
+ :es_url: http://localhost:9300
@@ -0,0 +1,44 @@
1
+ require 'rake/clean'
2
+ require 'rubygems'
3
+ require 'rubygems/package_task'
4
+ require 'rdoc/task'
5
+ require 'cucumber'
6
+ require 'cucumber/rake/task'
7
+ Rake::RDocTask.new do |rd|
8
+ rd.main = "README.rdoc"
9
+ rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
10
+ rd.title = 'Your application title'
11
+ end
12
+
13
+ spec = eval(File.read('es-cli.gemspec'))
14
+
15
+ Gem::PackageTask.new(spec) do |pkg|
16
+ end
17
+ CUKE_RESULTS = 'results.html'
18
+ CLEAN << CUKE_RESULTS
19
+ desc 'Run features'
20
+ Cucumber::Rake::Task.new(:features) do |t|
21
+ opts = "features --format html -o #{CUKE_RESULTS} --format progress -x"
22
+ opts += " --tags #{ENV['TAGS']}" if ENV['TAGS']
23
+ t.cucumber_opts = opts
24
+ t.fork = false
25
+ end
26
+
27
+ desc 'Run features tagged as work-in-progress (@wip)'
28
+ Cucumber::Rake::Task.new('features:wip') do |t|
29
+ tag_opts = ' --tags ~@pending'
30
+ tag_opts = ' --tags @wip'
31
+ t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty -x -s#{tag_opts}"
32
+ t.fork = false
33
+ end
34
+
35
+ task :cucumber => :features
36
+ task 'cucumber:wip' => 'features:wip'
37
+ task :wip => 'features:wip'
38
+ require 'rake/testtask'
39
+ Rake::TestTask.new do |t|
40
+ t.libs << "test"
41
+ t.test_files = FileList['test/*_test.rb']
42
+ end
43
+
44
+ task :default => [:test,:features]
@@ -0,0 +1,136 @@
1
+ #!/usr/bin/env ruby
2
+ require 'gli'
3
+ require 'elasticsearch'
4
+ require 'es-cli'
5
+ require 'awesome_print'
6
+
7
+
8
+ include GLI::App
9
+
10
+ program_desc 'Elasticsearch CLI'
11
+
12
+ version EsCli::VERSION
13
+
14
+ subcommand_option_handling :normal
15
+ arguments :strict
16
+
17
+ desc 'Prints the current active profile in YAML format'
18
+ switch [:pp, :printprofile]
19
+
20
+ desc 'Describe some flag here'
21
+ default_value 'default'
22
+ arg_name 'The profile to run'
23
+ flag [:p, :profile]
24
+
25
+ desc 'Runs subcommands, `help cluster` for a list of cluster subcommands'
26
+ command [:cluster, :c] do |c|
27
+ #c.desc 'Describe a switch to cluster'
28
+ #c.switch :s
29
+
30
+ #c.desc 'Describe a flag to cluster'
31
+ #c.default_value 'default'
32
+ #c.flag :f
33
+ # c.action do |global_options, options, args|
34
+ #
35
+ # # Your command logic here
36
+ #
37
+ # # If you have any errors, just raise them
38
+ # # raise "that command made no sense"
39
+ # client = Elasticsearch::Client.new( { :host => from_current_profile(global_options, :es_url) } )
40
+ # puts client.cluster
41
+ # end
42
+ c.arg 'profile', :optional
43
+ c.desc 'Print the cluster health'
44
+ c.command [:health, :h] do |all|
45
+ all.action do |globals, options, args|
46
+ ap globals[:client].cluster.health
47
+ end
48
+ end
49
+
50
+ end
51
+
52
+ desc 'Runs subcommands, `help nodes` for a list of cluster subcommands'
53
+ command [:nodes, :n] do |c|
54
+
55
+
56
+ #desc 'Describe some flag here'
57
+ #default_value 'the default'
58
+ #arg_name 'The name of the argument'
59
+ #flag [:f, :flagname]
60
+
61
+ c.command [:stats, :s] do |all|
62
+
63
+ all.flag [:m,:metric], :default_value => '_all',
64
+ :arg_name => 'metric',
65
+ :desc => '_all, breaker, fs, http, indices, jvm, network, os, process, thread_pool, transport'
66
+ all.desc 'Print the node stats'
67
+ all.action do |globals, options, args|
68
+ ap globals[:client].nodes.stats(:metric => options[:metric])
69
+ end
70
+ end
71
+
72
+ end
73
+
74
+ CONFIG_FILE_NAME = '.es-cli.yml'
75
+
76
+ # Load configuration options from `~/.es-cli.yml` if it exists
77
+ def load_config(global)
78
+ config_file_path = File.join(Dir.home, CONFIG_FILE_NAME)
79
+
80
+ if File.exists?(config_file_path)
81
+ require 'yaml'
82
+ file_settings = YAML.load_file(config_file_path)
83
+ global[:config].merge!(file_settings)
84
+ end
85
+
86
+ end
87
+
88
+ def from_current_profile(global, property)
89
+ global[:config][global[:config][:profile]][:es_url]
90
+ end
91
+
92
+ pre do |globals, command, options, args|
93
+
94
+ # Set up the default configuation
95
+ globals[:config] = {:profile => :default, :default => {:es_url => 'http://localhost:9200'}}
96
+
97
+ # Load configuration file if it exists
98
+ load_config globals
99
+
100
+ # Use a profile if it is provided
101
+ if globals[:profile]
102
+ profile = globals[:profile].to_sym
103
+ raise "Could not find profile #{profile.to_s}, check your ~/.es-cli.yml settings" unless globals[:config][profile]
104
+ globals[:config][:profile] = profile
105
+ end
106
+
107
+ # Setup the ES client
108
+ globals[:client] = Elasticsearch::Client.new({:host => from_current_profile(globals, :es_url), :log => false})
109
+
110
+ if globals[:printprofile]
111
+ require 'yaml'
112
+ puts ({ globals[:config][:profile] => globals[:config][globals[:config][:profile]] }).to_yaml
113
+ end
114
+ # Pre logic here
115
+ # Return true to proceed; false to abort and not call the
116
+ # chosen command
117
+ # Use skips_pre before a command to skip this block
118
+ # on that command only
119
+ true
120
+ end
121
+
122
+ post do |global, command, options, args|
123
+
124
+ # Post logic here
125
+ # Use skips_post before a command to skip this
126
+ # block on that command only
127
+ end
128
+
129
+ on_error do |exception|
130
+
131
+ # Error logic here
132
+ # return false to skip default error handling
133
+ true
134
+ end
135
+
136
+ exit run(ARGV)
@@ -0,0 +1,25 @@
1
+ # Ensure we require the local version and not one we might have installed already
2
+ require File.join([File.dirname(__FILE__),'lib','es-cli','version.rb'])
3
+ spec = Gem::Specification.new do |s|
4
+ s.name = 'es-cli'
5
+ s.version = EsCli::VERSION
6
+ s.author = 'Your Name Here'
7
+ s.email = 'your@email.address.com'
8
+ s.homepage = 'http://your.website.com'
9
+ s.platform = Gem::Platform::RUBY
10
+ s.summary = 'A description of your project'
11
+ s.files = `git ls-files`.split("
12
+ ")
13
+ s.require_paths << 'lib'
14
+ s.has_rdoc = true
15
+ s.extra_rdoc_files = ['README.rdoc','es-cli.rdoc']
16
+ s.rdoc_options << '--title' << 'es-cli' << '--main' << 'README.rdoc' << '-ri'
17
+ s.bindir = 'bin'
18
+ s.executables << 'es-cli'
19
+ s.add_development_dependency('rake')
20
+ s.add_development_dependency('rdoc')
21
+ s.add_development_dependency('aruba')
22
+ s.add_runtime_dependency('gli','2.13.0')
23
+ s.add_runtime_dependency('elasticsearch','~> 1.0')
24
+ s.add_runtime_dependency('awesome_print','~> 1.6')
25
+ end
@@ -0,0 +1,5 @@
1
+ = es-cli
2
+
3
+ Generate this with
4
+ es-cli rdoc
5
+ After you have described your command line interface
@@ -0,0 +1,8 @@
1
+ Feature: My bootstrapped app kinda works
2
+ In order to get going on coding my awesome app
3
+ I want to have aruba and cucumber setup
4
+ So I don't have to do it myself
5
+
6
+ Scenario: App just runs
7
+ When I get help for "es-cli"
8
+ Then the exit status should be 0
@@ -0,0 +1,6 @@
1
+ When /^I get help for "([^"]*)"$/ do |app_name|
2
+ @app_name = app_name
3
+ step %(I run `#{app_name} help`)
4
+ end
5
+
6
+ # Add more step definitions here
@@ -0,0 +1,15 @@
1
+ require 'aruba/cucumber'
2
+
3
+ ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
4
+ LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib')
5
+
6
+ Before do
7
+ # Using "announce" causes massive warnings on 1.9.2
8
+ @puts = true
9
+ @original_rubylib = ENV['RUBYLIB']
10
+ ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s
11
+ end
12
+
13
+ After do
14
+ ENV['RUBYLIB'] = @original_rubylib
15
+ end
@@ -0,0 +1,4 @@
1
+ require 'es-cli/version.rb'
2
+
3
+ # Add requires for other files you add to your project here, so
4
+ # you just need to require this one file in your bin file
@@ -0,0 +1,3 @@
1
+ module EsCli
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,14 @@
1
+ require 'test_helper'
2
+
3
+ class DefaultTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ end
7
+
8
+ def teardown
9
+ end
10
+
11
+ def test_the_truth
12
+ assert true
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ require 'test/unit'
2
+
3
+ # Add test libraries you want to use here, e.g. mocha
4
+
5
+ class Test::Unit::TestCase
6
+
7
+ # Add global extensions to the test case class here
8
+
9
+ end
metadata ADDED
@@ -0,0 +1,152 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: es-cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Your Name Here
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rdoc
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: aruba
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: gli
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 2.13.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 2.13.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: elasticsearch
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: awesome_print
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.6'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.6'
97
+ description:
98
+ email: your@email.address.com
99
+ executables:
100
+ - es-cli
101
+ extensions: []
102
+ extra_rdoc_files:
103
+ - README.rdoc
104
+ - es-cli.rdoc
105
+ files:
106
+ - ".gitignore"
107
+ - Gemfile
108
+ - Gemfile.lock
109
+ - README.md
110
+ - README.rdoc
111
+ - Rakefile
112
+ - bin/es-cli
113
+ - es-cli.gemspec
114
+ - es-cli.rdoc
115
+ - features/es-cli.feature
116
+ - features/step_definitions/es-cli_steps.rb
117
+ - features/support/env.rb
118
+ - lib/es-cli.rb
119
+ - lib/es-cli/version.rb
120
+ - test/default_test.rb
121
+ - test/test_helper.rb
122
+ homepage: http://your.website.com
123
+ licenses: []
124
+ metadata: {}
125
+ post_install_message:
126
+ rdoc_options:
127
+ - "--title"
128
+ - es-cli
129
+ - "--main"
130
+ - README.rdoc
131
+ - "-ri"
132
+ require_paths:
133
+ - lib
134
+ - lib
135
+ required_ruby_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ required_rubygems_version: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ requirements: []
146
+ rubyforge_project:
147
+ rubygems_version: 2.2.2
148
+ signing_key:
149
+ specification_version: 4
150
+ summary: A description of your project
151
+ test_files: []
152
+ has_rdoc: true