hammer_cli 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/cli_config.template.yml +4 -1
- data/doc/development_tips.md +2 -2
- data/doc/release_notes.md +13 -1
- data/lib/hammer_cli/apipie/option_definition.rb +3 -0
- data/lib/hammer_cli/defaults.rb +35 -16
- data/lib/hammer_cli/defaults_commands.rb +2 -2
- data/lib/hammer_cli/logger.rb +1 -1
- data/lib/hammer_cli/options/normalizers.rb +22 -10
- data/lib/hammer_cli/output/adapter/abstract.rb +5 -0
- data/lib/hammer_cli/output/adapter/csv.rb +5 -0
- data/lib/hammer_cli/output/adapter/table.rb +5 -0
- data/lib/hammer_cli/output/adapter/tree_structure.rb +5 -0
- data/lib/hammer_cli/output/output.rb +1 -1
- data/lib/hammer_cli/output/record_collection.rb +8 -4
- data/lib/hammer_cli/settings.rb +2 -0
- data/lib/hammer_cli/validator.rb +49 -1
- data/lib/hammer_cli/version.rb +1 -1
- data/locale/ca/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/ca/hammer-cli.edit.po +411 -0
- data/locale/ca/hammer-cli.po +338 -0
- data/locale/ca/hammer-cli.po.time_stamp +0 -0
- data/locale/de/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/de/hammer-cli.edit.po +16 -16
- data/locale/de/hammer-cli.po +25 -5
- data/locale/en/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/en/hammer-cli.edit.po +46 -26
- data/locale/en/hammer-cli.po +20 -3
- data/locale/en_GB/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/en_GB/hammer-cli.edit.po +25 -25
- data/locale/en_GB/hammer-cli.po +25 -5
- data/locale/es/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/es/hammer-cli.po +24 -6
- data/locale/fr/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/fr/hammer-cli.edit.po +26 -26
- data/locale/fr/hammer-cli.po +24 -6
- data/locale/hammer-cli.pot +50 -28
- data/locale/it/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/it/hammer-cli.edit.po +9 -9
- data/locale/it/hammer-cli.po +25 -5
- data/locale/ja/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/ja/hammer-cli.edit.po +9 -9
- data/locale/ja/hammer-cli.po +25 -5
- data/locale/ko/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/ko/hammer-cli.edit.po +9 -9
- data/locale/ko/hammer-cli.po +25 -5
- data/locale/pt_BR/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/pt_BR/hammer-cli.edit.po +6 -6
- data/locale/pt_BR/hammer-cli.po +25 -5
- data/locale/ru/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/ru/hammer-cli.edit.po +31 -30
- data/locale/ru/hammer-cli.po +25 -5
- data/locale/zh_CN/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/zh_CN/hammer-cli.edit.po +9 -9
- data/locale/zh_CN/hammer-cli.po +26 -6
- data/locale/zh_TW/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/zh_TW/hammer-cli.edit.po +9 -9
- data/locale/zh_TW/hammer-cli.po +25 -5
- data/test/functional/defaults_test.rb +12 -0
- data/test/reports/TEST-Fields-ContainerField-display-.xml +1 -1
- data/test/reports/TEST-Fields-ContainerField-display-blank-is-allowed.xml +5 -5
- data/test/reports/TEST-Fields-ContainerField-display-blank-is-not-allowed.xml +5 -5
- data/test/reports/TEST-Fields-ContainerField.xml +1 -1
- data/test/reports/TEST-Fields-Field-display-.xml +1 -1
- data/test/reports/TEST-Fields-Field-display-blank-is-allowed.xml +3 -3
- data/test/reports/TEST-Fields-Field-display-blank-is-not-allowed.xml +3 -3
- data/test/reports/TEST-Fields-Field-hide-blank-.xml +3 -3
- data/test/reports/TEST-Fields-Field-parameters.xml +2 -2
- data/test/reports/TEST-Fields-Field.xml +4 -4
- data/test/reports/TEST-HammerCLI-AbstractCommand-build-options.xml +5 -5
- data/test/reports/TEST-HammerCLI-AbstractCommand-exception-handler.xml +4 -4
- data/test/reports/TEST-HammerCLI-AbstractCommand-logging.xml +8 -10
- data/test/reports/TEST-HammerCLI-AbstractCommand-option-builder.xml +3 -3
- data/test/reports/TEST-HammerCLI-AbstractCommand-options.xml +3 -3
- data/test/reports/TEST-HammerCLI-AbstractCommand-output.xml +7 -7
- data/test/reports/TEST-HammerCLI-AbstractCommand-subcommand-behavior-remove-subcommand.xml +3 -3
- data/test/reports/TEST-HammerCLI-AbstractCommand-subcommand-behavior-subcommand-.xml +4 -4
- data/test/reports/TEST-HammerCLI-AbstractCommand-subcommand-behavior-subcommand.xml +3 -3
- data/test/reports/TEST-HammerCLI-AbstractCommand-subcommand-behavior.xml +1 -1
- data/test/reports/TEST-HammerCLI-AbstractCommand.xml +3 -3
- data/test/reports/TEST-HammerCLI-Apipie-Command-options.xml +3 -3
- data/test/reports/TEST-HammerCLI-Apipie-Command-resource-defined.xml +2 -2
- data/test/reports/TEST-HammerCLI-Apipie-Command-setting-resources.xml +7 -7
- data/test/reports/TEST-HammerCLI-Apipie-Command.xml +2 -2
- data/test/reports/TEST-HammerCLI-Apipie-OptionBuilder-aliasing-resources.xml +4 -4
- data/test/reports/TEST-HammerCLI-Apipie-OptionBuilder-filtering-options.xml +5 -5
- data/test/reports/TEST-HammerCLI-Apipie-OptionBuilder-required-options.xml +3 -3
- data/test/reports/TEST-HammerCLI-Apipie-OptionBuilder-setting-correct-normalizers.xml +2 -8
- data/test/reports/TEST-HammerCLI-Apipie-OptionBuilder-with-hash-params.xml +3 -3
- data/test/reports/TEST-HammerCLI-Apipie-OptionBuilder-with-one-simple-param.xml +5 -5
- data/test/reports/TEST-HammerCLI-Apipie-OptionBuilder.xml +1 -1
- data/test/reports/TEST-HammerCLI-Completer-command-completion.xml +12 -12
- data/test/reports/TEST-HammerCLI-Completer-option-value-completion.xml +6 -6
- data/test/reports/TEST-HammerCLI-Completer-subcommand-completion.xml +7 -7
- data/test/reports/TEST-HammerCLI-Completer.xml +1 -1
- data/test/reports/TEST-HammerCLI-CompleterLine-line-complete.xml +10 -10
- data/test/reports/TEST-HammerCLI-CompleterLine-splitting-words.xml +12 -12
- data/test/reports/TEST-HammerCLI-CompleterLine.xml +1 -1
- data/test/reports/TEST-HammerCLI-CompleterWord-complete-.xml +9 -9
- data/test/reports/TEST-HammerCLI-CompleterWord-quote.xml +5 -5
- data/test/reports/TEST-HammerCLI-CompleterWord-quoted-.xml +4 -4
- data/test/reports/TEST-HammerCLI-CompleterWord.xml +1 -1
- data/test/reports/TEST-HammerCLI-Connection.xml +8 -8
- data/test/reports/TEST-HammerCLI-ExceptionHandler.xml +8 -8
- data/test/reports/TEST-HammerCLI-I18n.xml +3 -3
- data/test/reports/TEST-HammerCLI-MainCommand-loading-context-password.xml +3 -3
- data/test/reports/TEST-HammerCLI-MainCommand-loading-context-username.xml +3 -3
- data/test/reports/TEST-HammerCLI-MainCommand-loading-context-verbose.xml +2 -2
- data/test/reports/TEST-HammerCLI-MainCommand-loading-context.xml +1 -1
- data/test/reports/TEST-HammerCLI-MainCommand.xml +1 -1
- data/test/reports/TEST-HammerCLI-Modules-find-by-name.xml +4 -4
- data/test/reports/TEST-HammerCLI-Modules-load-a-module-module-not-found.xml +4 -4
- data/test/reports/TEST-HammerCLI-Modules-load-a-module-module-runtime-exception.xml +4 -4
- data/test/reports/TEST-HammerCLI-Modules-load-a-module-success.xml +5 -5
- data/test/reports/TEST-HammerCLI-Modules-load-a-module.xml +1 -1
- data/test/reports/TEST-HammerCLI-Modules-load-all-modules.xml +2 -4
- data/test/reports/TEST-HammerCLI-Modules-names.xml +4 -4
- data/test/reports/TEST-HammerCLI-Modules.xml +1 -1
- data/test/reports/TEST-HammerCLI-OptionBuilderContainer.0.xml +1 -5
- data/test/reports/TEST-HammerCLI-OptionBuilderContainer.xml +5 -1
- data/test/reports/TEST-HammerCLI-Options-Normalizers-abstract.xml +2 -2
- data/test/reports/TEST-HammerCLI-Options-Normalizers-bool.xml +13 -13
- data/test/reports/TEST-HammerCLI-Options-Normalizers-datetime.xml +6 -6
- data/test/reports/TEST-HammerCLI-Options-Normalizers-enum.xml +5 -5
- data/test/reports/TEST-HammerCLI-Options-Normalizers-enumlist.xml +8 -8
- data/test/reports/TEST-HammerCLI-Options-Normalizers-json-input.xml +5 -5
- data/test/reports/TEST-HammerCLI-Options-Normalizers-key-value-list.xml +6 -26
- data/test/reports/TEST-HammerCLI-Options-Normalizers-list.xml +5 -5
- data/test/reports/TEST-HammerCLI-Options-Normalizers.xml +1 -1
- data/test/reports/TEST-HammerCLI-Options-OptionDefinition-context.xml +2 -2
- data/test/reports/TEST-HammerCLI-Options-OptionDefinition-formatters.xml +3 -3
- data/test/reports/TEST-HammerCLI-Options-OptionDefinition.xml +1 -1
- data/test/reports/TEST-HammerCLI-Output-Adapter-Abstract-error-messages.xml +5 -5
- data/test/reports/TEST-HammerCLI-Output-Adapter-Abstract-messages.xml +3 -3
- data/test/reports/TEST-HammerCLI-Output-Adapter-Abstract-test-data-for-field.xml +5 -5
- data/test/reports/TEST-HammerCLI-Output-Adapter-Abstract.xml +6 -6
- data/test/reports/TEST-HammerCLI-Output-Adapter-Base-print-collection-show-ids.xml +2 -2
- data/test/reports/TEST-HammerCLI-Output-Adapter-Base-print-collection.xml +11 -11
- data/test/reports/TEST-HammerCLI-Output-Adapter-Base.xml +1 -1
- data/test/reports/TEST-HammerCLI-Output-Adapter-CSValues-print-collection-formatters.xml +3 -3
- data/test/reports/TEST-HammerCLI-Output-Adapter-CSValues-print-collection-handle-fields-with-collections.xml +4 -4
- data/test/reports/TEST-HammerCLI-Output-Adapter-CSValues-print-collection-handle-fields-with-containers.xml +3 -3
- data/test/reports/TEST-HammerCLI-Output-Adapter-CSValues-print-collection-handle-ids.xml +3 -3
- data/test/reports/TEST-HammerCLI-Output-Adapter-CSValues-print-collection.xml +3 -3
- data/test/reports/TEST-HammerCLI-Output-Adapter-CSValues-print-message.xml +3 -3
- data/test/reports/TEST-HammerCLI-Output-Adapter-CSValues.xml +1 -1
- data/test/reports/TEST-HammerCLI-Output-Adapter-Table-print-collection-column-width.xml +5 -11
- data/test/reports/TEST-HammerCLI-Output-Adapter-Table-print-collection-formatters.xml +3 -3
- data/test/reports/TEST-HammerCLI-Output-Adapter-Table-print-collection-handle-ids.xml +3 -7
- data/test/reports/TEST-HammerCLI-Output-Adapter-Table-print-collection-sort-columns.xml +2 -2
- data/test/reports/TEST-HammerCLI-Output-Adapter-Table-print-collection.xml +3 -3
- data/test/reports/TEST-HammerCLI-Output-Adapter-Table.xml +1 -1
- data/test/reports/TEST-HammerCLI-Output-Definition-empty-.xml +3 -3
- data/test/reports/TEST-HammerCLI-Output-Definition.xml +3 -3
- data/test/reports/TEST-HammerCLI-Output-Dsl-collection.xml +4 -4
- data/test/reports/TEST-HammerCLI-Output-Dsl-custom-fields.xml +3 -3
- data/test/reports/TEST-HammerCLI-Output-Dsl-fields.xml +5 -5
- data/test/reports/TEST-HammerCLI-Output-Dsl-label.xml +4 -4
- data/test/reports/TEST-HammerCLI-Output-Dsl-path-definition.xml +4 -4
- data/test/reports/TEST-HammerCLI-Output-Dsl.xml +2 -2
- data/test/reports/TEST-HammerCLI-Output-FieldFilter.xml +4 -4
- data/test/reports/TEST-HammerCLI-Output-Formatters-BooleanFormatter.xml +3 -3
- data/test/reports/TEST-HammerCLI-Output-Formatters-ColorFormatter.xml +2 -2
- data/test/reports/TEST-HammerCLI-Output-Formatters-DateFormatter.xml +3 -3
- data/test/reports/TEST-HammerCLI-Output-Formatters-FieldFormatter.xml +4 -4
- data/test/reports/TEST-HammerCLI-Output-Formatters-FormatterContainer.xml +4 -4
- data/test/reports/TEST-HammerCLI-Output-Formatters-FormatterLibrary.xml +3 -3
- data/test/reports/TEST-HammerCLI-Output-Formatters-KeyValueFormatter.xml +4 -4
- data/test/reports/TEST-HammerCLI-Output-Formatters-ListFormatter.xml +4 -4
- data/test/reports/TEST-HammerCLI-Output-Formatters-LongTextFormatter.xml +4 -4
- data/test/reports/TEST-HammerCLI-Output-Output-adapters.xml +6 -6
- data/test/reports/TEST-HammerCLI-Output-Output-data.xml +5 -5
- data/test/reports/TEST-HammerCLI-Output-Output-formatters.xml +2 -2
- data/test/reports/TEST-HammerCLI-Output-Output-messages.xml +7 -7
- data/test/reports/TEST-HammerCLI-Output-Output.xml +1 -1
- data/test/reports/TEST-HammerCLI-Output-RecordCollection.xml +4 -4
- data/test/reports/TEST-HammerCLI-Settings-load-from-paths.xml +5 -5
- data/test/reports/TEST-HammerCLI-Settings.xml +10 -10
- data/test/reports/TEST-HammerCLI-ShellHistory-loading-old-history.xml +3 -3
- data/test/reports/TEST-HammerCLI-ShellHistory-saving-history.xml +5 -5
- data/test/reports/TEST-HammerCLI-ShellHistory.xml +1 -1
- data/test/reports/TEST-MiniTest-Spec.xml +1 -1
- data/test/reports/TEST-String-camelize.xml +3 -3
- data/test/reports/TEST-String-formatting.xml +6 -6
- data/test/reports/TEST-String-indent.xml +3 -3
- data/test/reports/{TEST-HammerCLI-interactive-.xml → TEST-String-interactive-.xml} +4 -4
- data/test/reports/TEST-String.xml +1 -1
- data/test/reports/TEST-constraints-HammerCLI-Validator-AllConstraint-exist-.xml +4 -4
- data/test/reports/TEST-constraints-HammerCLI-Validator-AllConstraint.xml +1 -1
- data/test/reports/TEST-constraints-HammerCLI-Validator-AnyConstraint-exist-.xml +4 -4
- data/test/reports/TEST-constraints-HammerCLI-Validator-AnyConstraint.xml +1 -1
- data/test/reports/TEST-constraints-HammerCLI-Validator-BaseConstraint-exist-.xml +2 -2
- data/test/reports/TEST-constraints-HammerCLI-Validator-BaseConstraint-rejected.xml +4 -4
- data/test/reports/TEST-constraints-HammerCLI-Validator-BaseConstraint-required.xml +4 -4
- data/test/reports/TEST-constraints-HammerCLI-Validator-BaseConstraint.xml +1 -1
- data/test/reports/TEST-constraints.xml +1 -1
- data/test/unit/apipie/option_definition_test.rb +9 -0
- data/test/unit/defaults_test.rb +84 -22
- data/test/unit/fixtures/defaults/defaults_dashed.yml +6 -0
- data/test/unit/options/normalizers_test.rb +46 -34
- data/test/unit/output/adapter/abstract_test.rb +4 -0
- data/test/unit/output/adapter/base_test.rb +4 -0
- data/test/unit/output/adapter/csv_test.rb +4 -0
- data/test/unit/output/adapter/json_test.rb +4 -0
- data/test/unit/output/adapter/table_test.rb +19 -3
- data/test/unit/output/adapter/yaml_test.rb +4 -0
- data/test/unit/output/record_collection_test.rb +26 -0
- data/test/unit/settings_test.rb +11 -1
- data/test/unit/validator_test.rb +111 -6
- metadata +192 -247
- data/test/reports/TEST-Fields-Label-display-.xml +0 -7
- data/test/reports/TEST-Fields-Label-display-blank-is-allowed.xml +0 -15
- data/test/reports/TEST-Fields-Label-display-blank-is-not-allowed.xml +0 -15
- data/test/reports/TEST-Fields-Label.xml +0 -7
- data/test/reports/TEST-HammerCLI-Apipie-Command-reload-apipie-cache.xml +0 -11
- data/test/reports/TEST-HammerCLI-Apipie-OptionBuilder-setting-referenced-resources.xml +0 -9
- data/test/reports/TEST-HammerCLI-Apipie-OptionDefinition-referenced-resource.xml +0 -13
- data/test/reports/TEST-HammerCLI-Apipie-OptionDefinition.xml +0 -7
- data/test/reports/TEST-HammerCLI-Defaults.xml +0 -19
- data/test/reports/TEST-HammerCLI-Options-Matcher.xml +0 -17
- data/test/reports/TEST-HammerCLI-Options-Normalizers-number.xml +0 -11
- data/test/reports/TEST-HammerCLI-Options-OptionDefinition-deprecated-options.xml +0 -11
- data/test/reports/TEST-HammerCLI-Output-Adapter-Json-print-collection-show-ids.xml +0 -9
- data/test/reports/TEST-HammerCLI-Output-Adapter-Json-print-collection.xml +0 -27
- data/test/reports/TEST-HammerCLI-Output-Adapter-Json-print-message.xml +0 -11
- data/test/reports/TEST-HammerCLI-Output-Adapter-Json.xml +0 -7
- data/test/reports/TEST-HammerCLI-Output-Adapter-Yaml-print-collection-show-ids.xml +0 -9
- data/test/reports/TEST-HammerCLI-Output-Adapter-Yaml-print-collection.xml +0 -27
- data/test/reports/TEST-HammerCLI-Output-Adapter-Yaml-print-message.xml +0 -11
- data/test/reports/TEST-HammerCLI-Output-Adapter-Yaml.xml +0 -7
- data/test/reports/TEST-HammerCLI-constant-path.xml +0 -15
- data/test/reports/TEST-HammerCLI.xml +0 -7
- data/test/reports/TEST-Logging-LogEvent-filtering.xml +0 -9
- data/test/reports/TEST-Logging-LogEvent.xml +0 -7
- data/test/reports/TEST-String-constantize.xml +0 -15
- data/test/reports/TEST-String-underscore.xml +0 -13
- data/test/reports/TEST-commands-defaults-add.xml +0 -21
- data/test/reports/TEST-commands-defaults-delete.xml +0 -11
- data/test/reports/TEST-commands-defaults-list.xml +0 -11
- data/test/reports/TEST-commands-defaults-providers.xml +0 -11
- data/test/reports/TEST-commands.xml +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b39b8afbf9c00645ca1591288ec35f790efba222
|
4
|
+
data.tar.gz: b1b69c66682a9a1b38d2799f15c11da797990ca5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 403d600bba083967627d060ac6a6ae9620418fce83ac27ad0bd4b44821f42928fcdb0021e45166000b78f28988a7d1dca04344a1ad0d33216300b8475cba57ec
|
7
|
+
data.tar.gz: a572704192a70b48c30df2d2d6e2496a992034c3053300d772bd9a1ea51a5c3e40ba4dfba814f5ce20e03df40185f79166df3746db52b860429b8211e2f16722
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Enable interactive queries?
|
4
4
|
:interactive: true
|
5
5
|
# Number of records listed per page
|
6
|
-
:per_page: 20
|
6
|
+
# :per_page: 20
|
7
7
|
# Location of shell history file
|
8
8
|
:history_file: '~/.hammer/history'
|
9
9
|
|
@@ -26,5 +26,8 @@
|
|
26
26
|
# Maximum log size in bytes. Log rotates when the value gets exceeded
|
27
27
|
#:log_size: 5 #in MB
|
28
28
|
|
29
|
+
# Log record pattern (logging gem syntax)
|
30
|
+
#:log_pattern: '[%5l %d %c] %m'
|
31
|
+
|
29
32
|
# Mark translated strings with X characters (for developers)
|
30
33
|
#:mark_translated: false
|
data/doc/development_tips.md
CHANGED
@@ -2,7 +2,7 @@ Development Tips
|
|
2
2
|
----------------
|
3
3
|
|
4
4
|
### Local gem modifications
|
5
|
-
If you want to modify the gems setup for development needs, create a file `Gemfile.local` in the root of your hammer-cli checkout. You can override the setup from `Gemfile` there. This file is git-ignored so you can easily keep your custom tuning.
|
5
|
+
If you want to modify the gems setup for development needs, create a file `Gemfile.local.rb` in the root of your hammer-cli checkout. You can override the setup from `Gemfile` there. This file is git-ignored so you can easily keep your custom tuning.
|
6
6
|
|
7
7
|
Typical usage is for linking plugins from local checkouts:
|
8
8
|
```ruby
|
@@ -13,7 +13,7 @@ gem 'hammer_cli_foreman', :path => '../hammer-cli-foreman'
|
|
13
13
|
[Pry](https://github.com/pry/pry) is a runtime developer console for ruby.
|
14
14
|
It allows debugging when [Pry Debugger](https://github.com/nixme/pry-debugger) is installed alongside.
|
15
15
|
|
16
|
-
For basic usage, add following the lines to your `Gemfile.local`:
|
16
|
+
For basic usage, add following the lines to your `Gemfile.local.rb`:
|
17
17
|
|
18
18
|
```ruby
|
19
19
|
gem 'pry'
|
data/doc/release_notes.md
CHANGED
@@ -1,7 +1,19 @@
|
|
1
1
|
Release notes
|
2
2
|
=============
|
3
3
|
|
4
|
-
### 0.
|
4
|
+
### 0.7.0 (2016-06-14)
|
5
|
+
* Let print adapters decide whether to paginate ([#15257](http://projects.theforeman.org/issues/15257))
|
6
|
+
* Add support for testing values in option validation ([#13832](http://projects.theforeman.org/issues/13832))
|
7
|
+
* Add one_of constraint for option validator ([#13832](http://projects.theforeman.org/issues/13832))
|
8
|
+
* Descriptions from Apipie will not contain unescaped HTML ([#14598](http://projects.theforeman.org/issues/14598))
|
9
|
+
* Allow param names to contain dashes ([#8015](http://projects.theforeman.org/issues/8015))
|
10
|
+
* Add Catalan language ([#14947](http://projects.theforeman.org/issues/14947))
|
11
|
+
* Add support for Gemfile.local.rb ([#14466](http://projects.theforeman.org/issues/14466))
|
12
|
+
* Introduced log format setting ([#14591](http://projects.theforeman.org/issues/14591))
|
13
|
+
* Add pagination info when incomplete data are received (http://projects.theforeman.org/issues/14530)
|
14
|
+
* Array is merged across YAML settings ([#14590](http://projects.theforeman.org/issues/14590))
|
15
|
+
* Now hammer recognizes when to create defaults file correctly ([#14311](http://projects.theforeman.org/issues/14311))
|
16
|
+
* Enable json for key=value parameters ([#12869](http://projects.theforeman.org/issues/12869))
|
5
17
|
* Fix coded options for apipie 0.3.6 ([#13960](http://projects.theforeman.org/issues/13960))
|
6
18
|
|
7
19
|
### 0.6.0 (2016-02-25)
|
@@ -11,6 +11,9 @@ module HammerCLI::Apipie
|
|
11
11
|
self.referenced_resource = options.delete(:referenced_resource).to_s if options[:referenced_resource]
|
12
12
|
end
|
13
13
|
super
|
14
|
+
# Apipie currently sends descriptions as escaped HTML once this is changed this should be removed.
|
15
|
+
# See #15198 on Redmine.
|
16
|
+
@description = CGI::unescapeHTML(description)
|
14
17
|
end
|
15
18
|
|
16
19
|
end
|
data/lib/hammer_cli/defaults.rb
CHANGED
@@ -23,32 +23,37 @@ module HammerCLI
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def delete_default_from_conf(param)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
conf_file
|
26
|
+
update_defaults_file do |defaults|
|
27
|
+
defaults.delete_if { |k,| defaults_match?(k, param) }
|
28
|
+
end
|
30
29
|
end
|
31
30
|
|
32
31
|
def add_defaults_to_conf(default_options, provider)
|
33
|
-
create_default_file if defaults_settings.
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
32
|
+
create_default_file if defaults_settings.empty?
|
33
|
+
update_defaults_file do |defaults|
|
34
|
+
default_options.each do |key, value|
|
35
|
+
key = key.to_sym
|
36
|
+
defaults.delete_if { |k,| defaults_match?(k, key) }
|
37
|
+
defaults[key] = (value ? {:value => value,} : {:provider => provider})
|
38
|
+
end
|
39
39
|
end
|
40
|
-
|
41
|
-
|
40
|
+
end
|
41
|
+
|
42
|
+
def defaults_set?(param)
|
43
|
+
defaults_settings.keys.any? { |k| defaults_match?(k, param) }
|
42
44
|
end
|
43
45
|
|
44
46
|
def get_defaults(opt)
|
45
47
|
option = opt
|
46
48
|
option = opt.gsub("option_",'') if opt.include? "option_"
|
47
|
-
unless defaults_settings.nil?
|
48
|
-
|
49
|
-
|
49
|
+
unless defaults_settings.nil?
|
50
|
+
option_key = defaults_settings[option.to_sym].nil? ? option.gsub('_','-').to_sym : option.to_sym
|
51
|
+
return nil if defaults_settings[option_key].nil?
|
52
|
+
|
53
|
+
if defaults_settings[option_key][:provider]
|
54
|
+
providers[defaults_settings[option_key][:provider]].get_defaults(option.to_sym)
|
50
55
|
else
|
51
|
-
defaults_settings[
|
56
|
+
defaults_settings[option_key][:value]
|
52
57
|
end
|
53
58
|
end
|
54
59
|
end
|
@@ -72,6 +77,20 @@ module HammerCLI
|
|
72
77
|
raise DefaultsPathError.new(_("Couldn't create %s please create the path before defaults are enabled.") % path)
|
73
78
|
end
|
74
79
|
end
|
80
|
+
|
81
|
+
def update_defaults_file
|
82
|
+
conf_file = YAML.load_file(@path)
|
83
|
+
conf_file[:defaults] ||= {}
|
84
|
+
yield conf_file[:defaults]
|
85
|
+
write_to_file conf_file
|
86
|
+
conf_file
|
87
|
+
end
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
def defaults_match?(default_a, default_b)
|
92
|
+
default_a.to_s.gsub('-','_') == default_b.to_s.gsub('-','_')
|
93
|
+
end
|
75
94
|
end
|
76
95
|
|
77
96
|
def self.defaults
|
@@ -87,7 +87,7 @@ module HammerCLI
|
|
87
87
|
option "--param-name", "OPTION_NAME", _("The name of the default option"), :required => true
|
88
88
|
|
89
89
|
def execute
|
90
|
-
if context[:defaults]
|
90
|
+
if context[:defaults] && context[:defaults].defaults_set?(option_param_name)
|
91
91
|
context[:defaults].delete_default_from_conf(option_param_name.to_sym)
|
92
92
|
param_deleted(option_param_name)
|
93
93
|
else
|
@@ -115,7 +115,7 @@ module HammerCLI
|
|
115
115
|
if !context[:defaults].providers.key?(namespace)
|
116
116
|
provider_prob_message(namespace)
|
117
117
|
return HammerCLI::EX_USAGE
|
118
|
-
elsif !context[:defaults].providers[namespace].param_supported?(option_param_name)
|
118
|
+
elsif !context[:defaults].providers[namespace].param_supported?(option_param_name.gsub('-','_'))
|
119
119
|
defaults_not_supported_by_provider
|
120
120
|
return HammerCLI::EX_CONFIG
|
121
121
|
end
|
data/lib/hammer_cli/logger.rb
CHANGED
@@ -45,7 +45,7 @@ module HammerCLI
|
|
45
45
|
:file => :yellow,
|
46
46
|
:method => :yellow)
|
47
47
|
|
48
|
-
pattern = "[%5l %d %c] %m\n"
|
48
|
+
pattern = "#{HammerCLI::Settings.get(:log_pattern) || '[%5l %d %c] %m'}\n"
|
49
49
|
COLOR_LAYOUT = Logging::Layouts::Pattern.new(:pattern => pattern, :color_scheme => 'bright')
|
50
50
|
NOCOLOR_LAYOUT = Logging::Layouts::Pattern.new(:pattern => pattern, :color_scheme => nil)
|
51
51
|
DEFAULT_LOG_DIR = '/var/log/hammer'
|
@@ -22,6 +22,9 @@ module HammerCLI
|
|
22
22
|
|
23
23
|
class KeyValueList < AbstractNormalizer
|
24
24
|
|
25
|
+
PAIR_RE = '([^,=]+)=([^,\[]+|\[[^\[\]]*\])'
|
26
|
+
FULL_RE = "^((%s)[,]?)+$" % PAIR_RE
|
27
|
+
|
25
28
|
def description
|
26
29
|
_("Comma-separated list of key=value.")
|
27
30
|
end
|
@@ -30,26 +33,35 @@ module HammerCLI
|
|
30
33
|
return {} unless val.is_a?(String)
|
31
34
|
return {} if val.empty?
|
32
35
|
|
33
|
-
|
36
|
+
if valid_key_value?(val)
|
37
|
+
parse_key_value(val)
|
38
|
+
else
|
39
|
+
begin
|
40
|
+
formatter = JSONInput.new
|
41
|
+
formatter.format(val)
|
42
|
+
rescue ArgumentError
|
43
|
+
raise ArgumentError, _("value must be defined as a comma-separated list of key=value or valid JSON")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
34
47
|
|
35
|
-
|
36
|
-
full_re = "^((%s)[,]?)+$" % pair_re
|
48
|
+
private
|
37
49
|
|
38
|
-
|
39
|
-
|
40
|
-
|
50
|
+
def valid_key_value?(val)
|
51
|
+
Regexp.new(FULL_RE).match(val)
|
52
|
+
end
|
41
53
|
|
42
|
-
|
54
|
+
def parse_key_value(val)
|
55
|
+
result = {}
|
56
|
+
val.scan(Regexp.new(PAIR_RE)) do |key, value|
|
43
57
|
value = value.strip
|
44
58
|
value = value.scan(/[^,\[\]]+/) if value.start_with?('[')
|
45
59
|
|
46
60
|
result[key.strip] = strip_value(value)
|
47
61
|
end
|
48
|
-
|
62
|
+
result
|
49
63
|
end
|
50
64
|
|
51
|
-
private
|
52
|
-
|
53
65
|
def strip_value(value)
|
54
66
|
if value.is_a? Array
|
55
67
|
value.map do |item|
|
@@ -9,6 +9,11 @@ module HammerCLI::Output::Adapter
|
|
9
9
|
def initialize(context={}, formatters={})
|
10
10
|
@context = context
|
11
11
|
@formatters = HammerCLI::Output::Formatters::FormatterLibrary.new(filter_formatters(formatters))
|
12
|
+
@paginate_by_default = true
|
13
|
+
end
|
14
|
+
|
15
|
+
def paginate_by_default?
|
16
|
+
!!@paginate_by_default
|
12
17
|
end
|
13
18
|
|
14
19
|
def print_message(msg, msg_params={})
|
@@ -57,6 +57,11 @@ module HammerCLI::Output::Adapter
|
|
57
57
|
puts dashes[1] if dashes
|
58
58
|
puts output
|
59
59
|
puts dashes[1] if dashes
|
60
|
+
|
61
|
+
if collection.meta.pagination_set? && collection.count < collection.meta.subtotal
|
62
|
+
pages = (collection.meta.subtotal.to_f/collection.meta.per_page).ceil
|
63
|
+
puts _("Page #{collection.meta.page} of #{pages} (use --page and --per-page for navigation)")
|
64
|
+
end
|
60
65
|
end
|
61
66
|
|
62
67
|
protected
|
@@ -1,6 +1,11 @@
|
|
1
1
|
module HammerCLI::Output::Adapter
|
2
2
|
class TreeStructure < Abstract
|
3
3
|
|
4
|
+
def initialize(context={}, formatters={})
|
5
|
+
super
|
6
|
+
@paginate_by_default = false
|
7
|
+
end
|
8
|
+
|
4
9
|
def prepare_collection(fields, collection)
|
5
10
|
collection.map do |element|
|
6
11
|
render_fields(fields, element)
|
@@ -66,7 +66,7 @@ module HammerCLI::Output
|
|
66
66
|
|
67
67
|
def init_adapter(adapter_name)
|
68
68
|
raise NameError unless self.class.adapters.has_key? adapter_name
|
69
|
-
self.class.adapters[adapter_name].new(context, self.class.formatters)
|
69
|
+
@adapter ||= self.class.adapters[adapter_name].new(context, self.class.formatters)
|
70
70
|
end
|
71
71
|
|
72
72
|
end
|
@@ -6,15 +6,19 @@ module HammerCLI::Output
|
|
6
6
|
attr_accessor :total, :subtotal, :page, :per_page, :search, :sort_by, :sort_order
|
7
7
|
|
8
8
|
def initialize(options={})
|
9
|
-
@total = options[:total]
|
10
|
-
@subtotal = options[:subtotal]
|
11
|
-
@page = options[:page]
|
12
|
-
@per_page = options[:per_page]
|
9
|
+
@total = options[:total].to_i if options[:total]
|
10
|
+
@subtotal = options[:subtotal].to_i if options[:subtotal]
|
11
|
+
@page = options[:page].to_i if options[:page]
|
12
|
+
@per_page = options[:per_page].to_i if options[:per_page]
|
13
13
|
@search = options[:search]
|
14
14
|
@sort_by = options[:sort_by]
|
15
15
|
@sort_order = options[:sort_order]
|
16
16
|
end
|
17
17
|
|
18
|
+
def pagination_set?
|
19
|
+
!(@total.nil? || @subtotal.nil? || @page.nil? || @per_page.nil?)
|
20
|
+
end
|
21
|
+
|
18
22
|
end
|
19
23
|
|
20
24
|
|
data/lib/hammer_cli/settings.rb
CHANGED
data/lib/hammer_cli/validator.rb
CHANGED
@@ -71,6 +71,17 @@ module HammerCLI
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
+
class OneOptionConstraint < AllConstraint
|
75
|
+
def initialize(options, to_check)
|
76
|
+
super(options, [to_check])
|
77
|
+
@rejected_msg = _("You can't set option %s")
|
78
|
+
@required_msg = _("Option %s is required")
|
79
|
+
end
|
80
|
+
|
81
|
+
def value
|
82
|
+
get_option(@to_check[0]).get
|
83
|
+
end
|
84
|
+
end
|
74
85
|
|
75
86
|
class AnyConstraint < BaseConstraint
|
76
87
|
|
@@ -89,6 +100,39 @@ module HammerCLI
|
|
89
100
|
end
|
90
101
|
|
91
102
|
|
103
|
+
class OneOfConstraint < BaseConstraint
|
104
|
+
def initialize(options, to_check)
|
105
|
+
raise 'Set at least one expected option' if to_check.empty?
|
106
|
+
super(options, to_check)
|
107
|
+
end
|
108
|
+
|
109
|
+
def rejected
|
110
|
+
raise NotImplementedError, '#rejected is unsupported for OneOfConstraint'
|
111
|
+
end
|
112
|
+
|
113
|
+
def required_msg
|
114
|
+
case count_present_options
|
115
|
+
when 0
|
116
|
+
_("One of options %s is required")
|
117
|
+
when 1
|
118
|
+
''
|
119
|
+
else
|
120
|
+
_("Only one of options %s can be set")
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def exist?
|
125
|
+
return count_present_options == 1
|
126
|
+
end
|
127
|
+
|
128
|
+
protected
|
129
|
+
def count_present_options
|
130
|
+
@to_check.count do |opt|
|
131
|
+
option_passed?(opt)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
92
136
|
def initialize(options)
|
93
137
|
@options = options
|
94
138
|
end
|
@@ -98,13 +142,17 @@ module HammerCLI
|
|
98
142
|
end
|
99
143
|
|
100
144
|
def option(to_check)
|
101
|
-
|
145
|
+
OneOptionConstraint.new(@options, to_check)
|
102
146
|
end
|
103
147
|
|
104
148
|
def any(*to_check)
|
105
149
|
AnyConstraint.new(@options, to_check.flatten(1))
|
106
150
|
end
|
107
151
|
|
152
|
+
def one_of(*to_check)
|
153
|
+
OneOfConstraint.new(@options, to_check.flatten(1))
|
154
|
+
end
|
155
|
+
|
108
156
|
def run(&block)
|
109
157
|
self.instance_eval &block
|
110
158
|
end
|
data/lib/hammer_cli/version.rb
CHANGED
Binary file
|