solr_makr 0.0.4 → 0.5.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.
- checksums.yaml +4 -4
- data/.agignore +1 -0
- data/README.md +24 -2
- data/Rakefile +1 -1
- data/bin/console +13 -0
- data/exe/solr-makr +9 -0
- data/lib/solr_makr.rb +76 -23
- data/lib/solr_makr/application.rb +24 -44
- data/lib/solr_makr/application_action.rb +182 -0
- data/lib/solr_makr/application_dispatch.rb +85 -0
- data/lib/solr_makr/collection.rb +17 -0
- data/lib/solr_makr/commands.rb +14 -0
- data/lib/solr_makr/commands/abstract_command.rb +60 -0
- data/lib/solr_makr/commands/buffer.rb +98 -0
- data/lib/solr_makr/commands/create_collection.rb +57 -0
- data/lib/solr_makr/commands/delete_collection.rb +13 -0
- data/lib/solr_makr/commands/execute.rb +67 -0
- data/lib/solr_makr/commands/fetch_collection_list.rb +17 -0
- data/lib/solr_makr/commands/push_config.rb +36 -0
- data/lib/solr_makr/commands/reload_collection.rb +13 -0
- data/lib/solr_makr/commands/set_up_local_configuration.rb +27 -0
- data/lib/solr_makr/commands/write_yaml.rb +28 -19
- data/lib/solr_makr/configsets.rb +15 -0
- data/lib/solr_makr/configsets/directory.rb +32 -0
- data/lib/solr_makr/configsets/get_nodes.rb +33 -0
- data/lib/solr_makr/configsets/install_default.rb +17 -0
- data/lib/solr_makr/configsets/lookup_dependent_collections.rb +20 -0
- data/lib/solr_makr/configsets/node.rb +56 -0
- data/lib/solr_makr/configsets/push_to_zookeeper.rb +19 -0
- data/lib/solr_makr/configsets/remote.rb +30 -0
- data/lib/solr_makr/configuration.rb +45 -0
- data/lib/solr_makr/errors/halt_execution.rb +4 -0
- data/lib/solr_makr/files/default-configset/README.md +1 -0
- data/lib/solr_makr/files/default-configset/conf/_rest_managed.json +1 -0
- data/lib/solr_makr/files/default-configset/conf/admin-extra.html +31 -0
- data/lib/solr_makr/files/default-configset/conf/currency.xml +67 -0
- data/lib/solr_makr/files/default-configset/conf/elevate.xml +1672 -0
- data/lib/solr_makr/files/default-configset/conf/lang/stopwords_en.txt +54 -0
- data/lib/solr_makr/files/default-configset/conf/mapping-ISOLatin1Accent.txt +2586 -0
- data/lib/solr_makr/files/default-configset/conf/protwords.txt +1613 -0
- data/lib/{files → solr_makr/files/default-configset/conf}/schema.xml +132 -40
- data/lib/solr_makr/files/default-configset/conf/scripts.conf +1623 -0
- data/lib/{files → solr_makr/files/default-configset/conf}/solrconfig.xml +294 -328
- data/lib/solr_makr/files/default-configset/conf/spellings.txt +1534 -0
- data/lib/solr_makr/files/default-configset/conf/synonyms.txt +1646 -0
- data/lib/solr_makr/local_configuration.rb +42 -0
- data/lib/solr_makr/local_configuration/cache.rb +21 -0
- data/lib/solr_makr/local_configuration/config_directory.rb +17 -0
- data/lib/solr_makr/local_configuration/directory.rb +17 -0
- data/lib/solr_makr/local_configuration/helper.rb +19 -0
- data/lib/solr_makr/local_configuration/save_settings.rb +9 -0
- data/lib/solr_makr/local_configuration/settings.rb +50 -0
- data/lib/solr_makr/meta/abstract_runner.rb +36 -0
- data/lib/solr_makr/meta/application_logger.rb +13 -0
- data/lib/solr_makr/meta/buffer_interaction.rb +41 -0
- data/lib/solr_makr/meta/disable_paging.rb +6 -0
- data/lib/solr_makr/meta/has_solr_attributes.rb +13 -0
- data/lib/solr_makr/meta/indifferent_options.rb +13 -0
- data/lib/solr_makr/meta/option_definition.rb +105 -0
- data/lib/solr_makr/meta/option_mapping.rb +38 -0
- data/lib/solr_makr/meta/pathlike.rb +9 -0
- data/lib/solr_makr/meta/set_global_options.rb +23 -0
- data/lib/solr_makr/meta/utility.rb +99 -0
- data/lib/solr_makr/meta/wraps_directory.rb +27 -0
- data/lib/solr_makr/meta/wraps_path.rb +18 -0
- data/lib/solr_makr/solr_api.rb +12 -0
- data/lib/solr_makr/solr_api/client.rb +32 -0
- data/lib/solr_makr/solr_api/client_macros.rb +61 -0
- data/lib/solr_makr/solr_api/cluster_response.rb +21 -0
- data/lib/solr_makr/solr_api/endpoint.rb +15 -0
- data/lib/solr_makr/solr_api/list_response.rb +19 -0
- data/lib/solr_makr/solr_api/request_params.rb +50 -0
- data/lib/solr_makr/solr_api/response.rb +69 -0
- data/lib/solr_makr/sunspot_configuration.rb +49 -0
- data/lib/solr_makr/version.rb +1 -1
- data/solr_makr.gemspec +17 -9
- metadata +171 -31
- data/bin/solr-makr +0 -7
- data/lib/solr_makr/commands/create_core.rb +0 -21
- data/lib/solr_makr/commands/destroy_core.rb +0 -17
- data/lib/solr_makr/commands/list_cores.rb +0 -17
- data/lib/solr_makr/commands/shared.rb +0 -84
- data/lib/solr_makr/core.rb +0 -94
- data/lib/solr_makr/core_status.rb +0 -56
- data/lib/solr_makr/solr_configuration.rb +0 -84
- data/lib/solr_makr/solr_request.rb +0 -23
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2e4ea507a10b5bcd9b05ae529856fa3394456a34
|
|
4
|
+
data.tar.gz: 8a268eb91d40dba267e11f9bfdf1d8de8b05141c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0b29e04ce7b2fda319d937ed0747ba8d26dfa2b851377b9a5f2703f1b429b66eb45735a3f7e31f9406cd69469e621ba4cf6b0d75a8f04dfc07638d1b7f72668c
|
|
7
|
+
data.tar.gz: 185b6005cda2283402fe4026be8999e1269dcccaa2470d7002a85e1f0ccc0a859ee75ef5e541bb12487a4d1938ccee28f141b6d8beb906343417be25127b3438
|
data/.agignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
solr
|
data/README.md
CHANGED
|
@@ -2,17 +2,39 @@
|
|
|
2
2
|
|
|
3
3
|
Create and destroy solr cores programmatically.
|
|
4
4
|
|
|
5
|
+
Assumes Solr 5.x with zookeeper running on the default ports.
|
|
6
|
+
|
|
7
|
+
See `solr-makr --help` to customize port information.
|
|
8
|
+
|
|
5
9
|
## Installation
|
|
6
10
|
|
|
7
11
|
$ gem install solr_makr
|
|
8
12
|
|
|
9
13
|
## Usage
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
To set up:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
# only need to run once, to set up local configuration directory
|
|
19
|
+
|
|
20
|
+
solr-makr setup
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
To create a core:
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
solr-makr create --name foo
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
To generate a valid yaml configuration for use with sunspot:
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
solr-makr yaml --name foo -o sunspot.yml
|
|
33
|
+
```
|
|
12
34
|
|
|
13
35
|
## Contributing
|
|
14
36
|
|
|
15
|
-
1. Fork it ( https://github.com/scryptmouse/
|
|
37
|
+
1. Fork it ( https://github.com/scryptmouse/solr_makr/fork )
|
|
16
38
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
17
39
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
18
40
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/Rakefile
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
require "bundler/gem_tasks"
|
|
2
|
-
|
|
2
|
+
require "sunspot/solr/tasks"
|
data/bin/console
ADDED
data/exe/solr-makr
ADDED
data/lib/solr_makr.rb
CHANGED
|
@@ -1,44 +1,97 @@
|
|
|
1
1
|
require "fileutils"
|
|
2
|
+
require "find"
|
|
2
3
|
require "pathname"
|
|
4
|
+
require "set"
|
|
3
5
|
require "yaml"
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
alias_method :to_str, :to_s
|
|
7
|
-
end
|
|
8
|
-
|
|
7
|
+
require "active_support/callbacks"
|
|
9
8
|
require "active_support/concern"
|
|
10
9
|
require "active_support/configurable"
|
|
10
|
+
require 'active_support/core_ext/hash/indifferent_access'
|
|
11
11
|
require "active_support/core_ext/object/blank"
|
|
12
12
|
require "active_support/core_ext/object/try"
|
|
13
|
+
require "active_support/core_ext/object/with_options"
|
|
13
14
|
require "active_support/core_ext/module/delegation"
|
|
15
|
+
require "active_support/dependencies/autoload"
|
|
16
|
+
require "active_interaction"
|
|
14
17
|
require "attr_lazy"
|
|
15
18
|
require "commander"
|
|
16
|
-
require "
|
|
17
|
-
require "
|
|
19
|
+
require "httparty"
|
|
20
|
+
require "lmdb"
|
|
21
|
+
require "rugged"
|
|
22
|
+
require "toml"
|
|
23
|
+
require "terminal-table"
|
|
18
24
|
require "virtus"
|
|
25
|
+
require "zk"
|
|
19
26
|
|
|
20
27
|
require "solr_makr/version"
|
|
21
|
-
require "solr_makr/solr_request"
|
|
22
|
-
require "solr_makr/core_status"
|
|
23
|
-
require "solr_makr/solr_configuration"
|
|
24
|
-
require "solr_makr/core"
|
|
25
|
-
require "solr_makr/commands"
|
|
26
|
-
require "solr_makr/commands/shared"
|
|
27
|
-
require "solr_makr/commands/create_core"
|
|
28
|
-
require "solr_makr/commands/destroy_core"
|
|
29
|
-
require "solr_makr/commands/list_cores"
|
|
30
|
-
require "solr_makr/commands/write_yaml"
|
|
31
|
-
require "solr_makr/application"
|
|
32
28
|
|
|
33
29
|
module SolrMakr
|
|
30
|
+
extend ActiveSupport::Autoload
|
|
31
|
+
|
|
32
|
+
# Executable name.
|
|
33
|
+
BIN_NAME = 'solr-makr'
|
|
34
|
+
|
|
35
|
+
autoload :Application
|
|
36
|
+
autoload :ApplicationAction
|
|
37
|
+
autoload :ApplicationDispatch
|
|
38
|
+
autoload :Collection
|
|
39
|
+
autoload :Commands
|
|
40
|
+
autoload :Configsets
|
|
41
|
+
autoload :Configuration
|
|
42
|
+
autoload :LocalConfiguration
|
|
43
|
+
autoload :SolrAPI
|
|
44
|
+
autoload :SunspotConfiguration
|
|
45
|
+
|
|
46
|
+
autoload_under 'errors' do
|
|
47
|
+
autoload :HaltExecution
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
autoload_under 'meta' do
|
|
51
|
+
autoload :AbstractRunner
|
|
52
|
+
autoload :BufferInteraction
|
|
53
|
+
autoload :DisablePaging
|
|
54
|
+
autoload :HasSolrAttributes
|
|
55
|
+
autoload :IndifferentOptions
|
|
56
|
+
autoload :SetGlobalOptions
|
|
57
|
+
autoload :OptionDefinition
|
|
58
|
+
autoload :OptionMapping
|
|
59
|
+
autoload :Pathlike
|
|
60
|
+
autoload :Utility
|
|
61
|
+
autoload :WrapsDirectory
|
|
62
|
+
autoload :WrapsPath
|
|
63
|
+
end
|
|
64
|
+
|
|
34
65
|
class << self
|
|
35
|
-
|
|
66
|
+
delegate :with_zookeeper, to: :configuration
|
|
36
67
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
68
|
+
attr_lazy_reader :buffer do
|
|
69
|
+
SolrMakr::Commands::Buffer.new
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
delegate :logger, to: :buffer
|
|
73
|
+
|
|
74
|
+
attr_lazy_reader :configuration do
|
|
75
|
+
SolrMakr::Configuration.new
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
attr_lazy_reader :root do
|
|
79
|
+
Pathname.new(__dir__)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
attr_lazy_reader :files do
|
|
83
|
+
root.join('solr_makr', 'files')
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
attr_lazy_reader :default_configset do
|
|
87
|
+
files.join('default-configset')
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
attr_lazy_reader :local_configuration do
|
|
91
|
+
SolrMakr::LocalConfiguration
|
|
42
92
|
end
|
|
43
93
|
end
|
|
44
94
|
end
|
|
95
|
+
|
|
96
|
+
Commander::Command::Options.prepend SolrMakr::IndifferentOptions
|
|
97
|
+
Commander::UI.singleton_class.prepend SolrMakr::DisablePaging
|
|
@@ -2,60 +2,40 @@ module SolrMakr
|
|
|
2
2
|
class Application
|
|
3
3
|
include Commander::Methods
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
# @param [IO, File, #write] output
|
|
6
|
+
def initialize(output: STDOUT)
|
|
7
|
+
@output = output
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
program :version, SolrMakr::VERSION
|
|
10
|
-
program :description, 'Create a solr core programmatically'
|
|
11
|
-
program :help, 'Author', 'Alexa Grey <alexag@hranswerlink.com>'
|
|
12
|
-
program :help_formatter, Commander::HelpFormatter::TerminalCompact
|
|
13
|
-
|
|
14
|
-
default_command :help
|
|
15
|
-
|
|
16
|
-
global_option '-d', '--solr-home DIR', 'Path to the solr home directory'
|
|
17
|
-
global_option '-p', '--solr-port PORT', Integer, 'Port to use to communicate with the solr API'
|
|
18
|
-
global_option '-H', '--solr-host HOST', String, 'Host [default localhost]'
|
|
19
|
-
global_option '-V', '--verbose', 'Show verbose output.'
|
|
20
|
-
|
|
21
|
-
command :create do |c|
|
|
22
|
-
c.syntax = "#{NAME} create NAME"
|
|
23
|
-
|
|
24
|
-
c.description = "Create and register a solr core."
|
|
25
|
-
|
|
26
|
-
c.when_called Commands::CreateCore, :run!
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
command :list do |c|
|
|
30
|
-
c.syntax = "#{NAME} list"
|
|
31
|
-
|
|
32
|
-
c.description = "List installed solr cores."
|
|
33
|
-
|
|
34
|
-
c.when_called Commands::ListCores, :run!
|
|
35
|
-
end
|
|
9
|
+
@exit_status = 0
|
|
10
|
+
end
|
|
36
11
|
|
|
37
|
-
|
|
38
|
-
|
|
12
|
+
attr_reader :output
|
|
13
|
+
attr_reader :exit_status
|
|
39
14
|
|
|
40
|
-
|
|
15
|
+
delegate :configuration, to: SolrMakr
|
|
41
16
|
|
|
42
|
-
|
|
17
|
+
def run
|
|
18
|
+
program :name, SolrMakr::BIN_NAME
|
|
19
|
+
program :version, SolrMakr::VERSION
|
|
20
|
+
program :description, 'Create and manage solr collections via CLI'
|
|
21
|
+
program :help, 'Author', 'Alexa Grey <alexag@hranswerlink.com>'
|
|
43
22
|
|
|
44
|
-
|
|
45
|
-
end
|
|
23
|
+
default_command :help
|
|
46
24
|
|
|
47
|
-
|
|
48
|
-
|
|
25
|
+
global_option '-Z', '--zookeeper HOST', String, "Zookeeper host(s) [default: #{configuration.zookeeper}]"
|
|
26
|
+
global_option '-p', '--solr-port PORT', Integer, "Port solr is running on [default: #{configuration.solr_port}]"
|
|
27
|
+
global_option '-H', '--solr-host HOST', String, "Solr Host [default: #{configuration.solr_host}]"
|
|
28
|
+
global_option '-V', '--verbose', "Show verbose output."
|
|
49
29
|
|
|
50
|
-
|
|
30
|
+
ApplicationDispatch.generate_commands! self
|
|
51
31
|
|
|
52
|
-
|
|
32
|
+
run!.tap do |buffer|
|
|
33
|
+
if buffer.kind_of?(SolrMakr::Commands::Buffer)
|
|
34
|
+
output.write buffer.to_s
|
|
53
35
|
|
|
54
|
-
|
|
55
|
-
|
|
36
|
+
@exit_status = buffer.exit_status
|
|
37
|
+
end
|
|
56
38
|
end
|
|
57
|
-
|
|
58
|
-
run!
|
|
59
39
|
end
|
|
60
40
|
end
|
|
61
41
|
end
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
module SolrMakr
|
|
2
|
+
class ApplicationAction
|
|
3
|
+
include Virtus.model strict: true
|
|
4
|
+
|
|
5
|
+
attribute :name, String
|
|
6
|
+
attribute :command_name, String, default: :default_command_name
|
|
7
|
+
attribute :description, String, default: ''
|
|
8
|
+
attribute :requires_name, Boolean, default: false
|
|
9
|
+
attribute :multiple_names, Boolean, default: false
|
|
10
|
+
attribute :required_options, Set, default: proc { Set.new }
|
|
11
|
+
attribute :specifies_configset, Boolean, default: false
|
|
12
|
+
attribute :interaction, String, default: :derive_default_interaction
|
|
13
|
+
|
|
14
|
+
delegate :configuration, to: SolrMakr
|
|
15
|
+
|
|
16
|
+
# @return [SolrMakr::Commands::Buffer]
|
|
17
|
+
def execute(args, options)
|
|
18
|
+
buffer = SolrMakr::Commands::Buffer.new
|
|
19
|
+
|
|
20
|
+
execution = SolrMakr::Commands::Execute.run action: self, command_args: args, command_options: options
|
|
21
|
+
|
|
22
|
+
buffer.import execution.buffer
|
|
23
|
+
|
|
24
|
+
unless execution.valid?
|
|
25
|
+
execution.errors.full_messages.each do |error|
|
|
26
|
+
buffer.error error
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
return buffer
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def configure(&block)
|
|
34
|
+
initial_configuration
|
|
35
|
+
|
|
36
|
+
yield Configurator.new(self) if block_given?
|
|
37
|
+
|
|
38
|
+
return self
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# @param [Commander::Command] command
|
|
42
|
+
# @return [void]
|
|
43
|
+
def setup_command!(command)
|
|
44
|
+
command.syntax = "#{SolrMakr::BIN_NAME} #{command_name}"
|
|
45
|
+
|
|
46
|
+
if description.present?
|
|
47
|
+
command.description = description
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
add_options_to! command
|
|
51
|
+
|
|
52
|
+
format_command! command
|
|
53
|
+
|
|
54
|
+
command.when_called self, :execute
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def requires?(option_name)
|
|
58
|
+
option_mapping[option_name].try(:required?)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# @api private
|
|
62
|
+
# @param [<String>] args
|
|
63
|
+
# @param [Commander::Command::Options] options
|
|
64
|
+
# @return [void]
|
|
65
|
+
def set_default_options!(args, options)
|
|
66
|
+
option_mapping.each do |option|
|
|
67
|
+
option.set_default!(args, options)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
if default_options_formatter.respond_to?(:call)
|
|
71
|
+
instance_exec(args, options, &default_options_formatter)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
return nil
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# @api private
|
|
78
|
+
# @param [Commander::Command] command
|
|
79
|
+
# @return [void]
|
|
80
|
+
def format_command!(command)
|
|
81
|
+
if command_formatter.respond_to?(:call)
|
|
82
|
+
command_formatter.call(command)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
return nil
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# @!attribute [r] interaction_klass
|
|
89
|
+
# @return [Class]
|
|
90
|
+
attr_lazy_reader :interaction_klass do
|
|
91
|
+
"SolrMakr::Commands::#{interaction}".constantize
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# @!attribute [rw] default_options_formatter
|
|
95
|
+
# @api private
|
|
96
|
+
# @return [Proc]
|
|
97
|
+
attr_accessor :default_options_formatter
|
|
98
|
+
|
|
99
|
+
# @!attribute [rw] command_formatter
|
|
100
|
+
# @api private
|
|
101
|
+
# @return [Proc]
|
|
102
|
+
attr_accessor :command_formatter
|
|
103
|
+
|
|
104
|
+
attr_lazy_reader :option_mapping do
|
|
105
|
+
SolrMakr::OptionMapping.new
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# @param [Symbol] name
|
|
109
|
+
# @param [Hash] attributes
|
|
110
|
+
# @yieldparam [SolrMakr::OptionDefinition] option
|
|
111
|
+
# @yieldreturn [void]
|
|
112
|
+
def add_option!(name, **attributes, &configurator)
|
|
113
|
+
attributes[:name] = name
|
|
114
|
+
|
|
115
|
+
option = SolrMakr::OptionDefinition.new(attributes)
|
|
116
|
+
|
|
117
|
+
yield option if block_given?
|
|
118
|
+
|
|
119
|
+
option_mapping << option
|
|
120
|
+
|
|
121
|
+
return nil
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# @api private
|
|
125
|
+
# @return [String]
|
|
126
|
+
def derive_default_interaction
|
|
127
|
+
name.to_s.classify
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# @param [Commander::Command] command
|
|
131
|
+
# @return [void]
|
|
132
|
+
def add_options_to!(command)
|
|
133
|
+
option_mapping.add_to_command! command
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
# @api private
|
|
137
|
+
# @return [String]
|
|
138
|
+
def default_command_name
|
|
139
|
+
name.to_s.gsub(/_collections?\z/, '').humanize.downcase
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# @!attribute [r] initial_configuration
|
|
143
|
+
# @return [nil]
|
|
144
|
+
attr_lazy_reader :initial_configuration do
|
|
145
|
+
if requires_name?
|
|
146
|
+
add_option! :name, short_name: 'n', description: 'Name of the collection', type: String, required: true
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
if specifies_configset?
|
|
150
|
+
add_option! :configset, value_name: 'NAME', description: 'Name of the configset', type: String, required: true do |c|
|
|
151
|
+
c.default_value = proc { SolrMakr.configuration.default_configset }
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
# @api private
|
|
157
|
+
class Configurator
|
|
158
|
+
def initialize(action)
|
|
159
|
+
@action = action
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def description(new_description)
|
|
163
|
+
@action.description = new_description.to_s
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def format_command(&formatter)
|
|
167
|
+
@action.command_formatter = formatter
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
def default_options(&formatter)
|
|
171
|
+
@action.default_options_formatter = formatter
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def option(name, **attributes, &configurator)
|
|
175
|
+
@action.add_option!(name, **attributes, &configurator)
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
private
|
|
179
|
+
attr_reader :action
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
end
|