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.
Files changed (241) hide show
  1. checksums.yaml +4 -4
  2. data/config/cli_config.template.yml +4 -1
  3. data/doc/development_tips.md +2 -2
  4. data/doc/release_notes.md +13 -1
  5. data/lib/hammer_cli/apipie/option_definition.rb +3 -0
  6. data/lib/hammer_cli/defaults.rb +35 -16
  7. data/lib/hammer_cli/defaults_commands.rb +2 -2
  8. data/lib/hammer_cli/logger.rb +1 -1
  9. data/lib/hammer_cli/options/normalizers.rb +22 -10
  10. data/lib/hammer_cli/output/adapter/abstract.rb +5 -0
  11. data/lib/hammer_cli/output/adapter/csv.rb +5 -0
  12. data/lib/hammer_cli/output/adapter/table.rb +5 -0
  13. data/lib/hammer_cli/output/adapter/tree_structure.rb +5 -0
  14. data/lib/hammer_cli/output/output.rb +1 -1
  15. data/lib/hammer_cli/output/record_collection.rb +8 -4
  16. data/lib/hammer_cli/settings.rb +2 -0
  17. data/lib/hammer_cli/validator.rb +49 -1
  18. data/lib/hammer_cli/version.rb +1 -1
  19. data/locale/ca/LC_MESSAGES/hammer-cli.mo +0 -0
  20. data/locale/ca/hammer-cli.edit.po +411 -0
  21. data/locale/ca/hammer-cli.po +338 -0
  22. data/locale/ca/hammer-cli.po.time_stamp +0 -0
  23. data/locale/de/LC_MESSAGES/hammer-cli.mo +0 -0
  24. data/locale/de/hammer-cli.edit.po +16 -16
  25. data/locale/de/hammer-cli.po +25 -5
  26. data/locale/en/LC_MESSAGES/hammer-cli.mo +0 -0
  27. data/locale/en/hammer-cli.edit.po +46 -26
  28. data/locale/en/hammer-cli.po +20 -3
  29. data/locale/en_GB/LC_MESSAGES/hammer-cli.mo +0 -0
  30. data/locale/en_GB/hammer-cli.edit.po +25 -25
  31. data/locale/en_GB/hammer-cli.po +25 -5
  32. data/locale/es/LC_MESSAGES/hammer-cli.mo +0 -0
  33. data/locale/es/hammer-cli.po +24 -6
  34. data/locale/fr/LC_MESSAGES/hammer-cli.mo +0 -0
  35. data/locale/fr/hammer-cli.edit.po +26 -26
  36. data/locale/fr/hammer-cli.po +24 -6
  37. data/locale/hammer-cli.pot +50 -28
  38. data/locale/it/LC_MESSAGES/hammer-cli.mo +0 -0
  39. data/locale/it/hammer-cli.edit.po +9 -9
  40. data/locale/it/hammer-cli.po +25 -5
  41. data/locale/ja/LC_MESSAGES/hammer-cli.mo +0 -0
  42. data/locale/ja/hammer-cli.edit.po +9 -9
  43. data/locale/ja/hammer-cli.po +25 -5
  44. data/locale/ko/LC_MESSAGES/hammer-cli.mo +0 -0
  45. data/locale/ko/hammer-cli.edit.po +9 -9
  46. data/locale/ko/hammer-cli.po +25 -5
  47. data/locale/pt_BR/LC_MESSAGES/hammer-cli.mo +0 -0
  48. data/locale/pt_BR/hammer-cli.edit.po +6 -6
  49. data/locale/pt_BR/hammer-cli.po +25 -5
  50. data/locale/ru/LC_MESSAGES/hammer-cli.mo +0 -0
  51. data/locale/ru/hammer-cli.edit.po +31 -30
  52. data/locale/ru/hammer-cli.po +25 -5
  53. data/locale/zh_CN/LC_MESSAGES/hammer-cli.mo +0 -0
  54. data/locale/zh_CN/hammer-cli.edit.po +9 -9
  55. data/locale/zh_CN/hammer-cli.po +26 -6
  56. data/locale/zh_TW/LC_MESSAGES/hammer-cli.mo +0 -0
  57. data/locale/zh_TW/hammer-cli.edit.po +9 -9
  58. data/locale/zh_TW/hammer-cli.po +25 -5
  59. data/test/functional/defaults_test.rb +12 -0
  60. data/test/reports/TEST-Fields-ContainerField-display-.xml +1 -1
  61. data/test/reports/TEST-Fields-ContainerField-display-blank-is-allowed.xml +5 -5
  62. data/test/reports/TEST-Fields-ContainerField-display-blank-is-not-allowed.xml +5 -5
  63. data/test/reports/TEST-Fields-ContainerField.xml +1 -1
  64. data/test/reports/TEST-Fields-Field-display-.xml +1 -1
  65. data/test/reports/TEST-Fields-Field-display-blank-is-allowed.xml +3 -3
  66. data/test/reports/TEST-Fields-Field-display-blank-is-not-allowed.xml +3 -3
  67. data/test/reports/TEST-Fields-Field-hide-blank-.xml +3 -3
  68. data/test/reports/TEST-Fields-Field-parameters.xml +2 -2
  69. data/test/reports/TEST-Fields-Field.xml +4 -4
  70. data/test/reports/TEST-HammerCLI-AbstractCommand-build-options.xml +5 -5
  71. data/test/reports/TEST-HammerCLI-AbstractCommand-exception-handler.xml +4 -4
  72. data/test/reports/TEST-HammerCLI-AbstractCommand-logging.xml +8 -10
  73. data/test/reports/TEST-HammerCLI-AbstractCommand-option-builder.xml +3 -3
  74. data/test/reports/TEST-HammerCLI-AbstractCommand-options.xml +3 -3
  75. data/test/reports/TEST-HammerCLI-AbstractCommand-output.xml +7 -7
  76. data/test/reports/TEST-HammerCLI-AbstractCommand-subcommand-behavior-remove-subcommand.xml +3 -3
  77. data/test/reports/TEST-HammerCLI-AbstractCommand-subcommand-behavior-subcommand-.xml +4 -4
  78. data/test/reports/TEST-HammerCLI-AbstractCommand-subcommand-behavior-subcommand.xml +3 -3
  79. data/test/reports/TEST-HammerCLI-AbstractCommand-subcommand-behavior.xml +1 -1
  80. data/test/reports/TEST-HammerCLI-AbstractCommand.xml +3 -3
  81. data/test/reports/TEST-HammerCLI-Apipie-Command-options.xml +3 -3
  82. data/test/reports/TEST-HammerCLI-Apipie-Command-resource-defined.xml +2 -2
  83. data/test/reports/TEST-HammerCLI-Apipie-Command-setting-resources.xml +7 -7
  84. data/test/reports/TEST-HammerCLI-Apipie-Command.xml +2 -2
  85. data/test/reports/TEST-HammerCLI-Apipie-OptionBuilder-aliasing-resources.xml +4 -4
  86. data/test/reports/TEST-HammerCLI-Apipie-OptionBuilder-filtering-options.xml +5 -5
  87. data/test/reports/TEST-HammerCLI-Apipie-OptionBuilder-required-options.xml +3 -3
  88. data/test/reports/TEST-HammerCLI-Apipie-OptionBuilder-setting-correct-normalizers.xml +2 -8
  89. data/test/reports/TEST-HammerCLI-Apipie-OptionBuilder-with-hash-params.xml +3 -3
  90. data/test/reports/TEST-HammerCLI-Apipie-OptionBuilder-with-one-simple-param.xml +5 -5
  91. data/test/reports/TEST-HammerCLI-Apipie-OptionBuilder.xml +1 -1
  92. data/test/reports/TEST-HammerCLI-Completer-command-completion.xml +12 -12
  93. data/test/reports/TEST-HammerCLI-Completer-option-value-completion.xml +6 -6
  94. data/test/reports/TEST-HammerCLI-Completer-subcommand-completion.xml +7 -7
  95. data/test/reports/TEST-HammerCLI-Completer.xml +1 -1
  96. data/test/reports/TEST-HammerCLI-CompleterLine-line-complete.xml +10 -10
  97. data/test/reports/TEST-HammerCLI-CompleterLine-splitting-words.xml +12 -12
  98. data/test/reports/TEST-HammerCLI-CompleterLine.xml +1 -1
  99. data/test/reports/TEST-HammerCLI-CompleterWord-complete-.xml +9 -9
  100. data/test/reports/TEST-HammerCLI-CompleterWord-quote.xml +5 -5
  101. data/test/reports/TEST-HammerCLI-CompleterWord-quoted-.xml +4 -4
  102. data/test/reports/TEST-HammerCLI-CompleterWord.xml +1 -1
  103. data/test/reports/TEST-HammerCLI-Connection.xml +8 -8
  104. data/test/reports/TEST-HammerCLI-ExceptionHandler.xml +8 -8
  105. data/test/reports/TEST-HammerCLI-I18n.xml +3 -3
  106. data/test/reports/TEST-HammerCLI-MainCommand-loading-context-password.xml +3 -3
  107. data/test/reports/TEST-HammerCLI-MainCommand-loading-context-username.xml +3 -3
  108. data/test/reports/TEST-HammerCLI-MainCommand-loading-context-verbose.xml +2 -2
  109. data/test/reports/TEST-HammerCLI-MainCommand-loading-context.xml +1 -1
  110. data/test/reports/TEST-HammerCLI-MainCommand.xml +1 -1
  111. data/test/reports/TEST-HammerCLI-Modules-find-by-name.xml +4 -4
  112. data/test/reports/TEST-HammerCLI-Modules-load-a-module-module-not-found.xml +4 -4
  113. data/test/reports/TEST-HammerCLI-Modules-load-a-module-module-runtime-exception.xml +4 -4
  114. data/test/reports/TEST-HammerCLI-Modules-load-a-module-success.xml +5 -5
  115. data/test/reports/TEST-HammerCLI-Modules-load-a-module.xml +1 -1
  116. data/test/reports/TEST-HammerCLI-Modules-load-all-modules.xml +2 -4
  117. data/test/reports/TEST-HammerCLI-Modules-names.xml +4 -4
  118. data/test/reports/TEST-HammerCLI-Modules.xml +1 -1
  119. data/test/reports/TEST-HammerCLI-OptionBuilderContainer.0.xml +1 -5
  120. data/test/reports/TEST-HammerCLI-OptionBuilderContainer.xml +5 -1
  121. data/test/reports/TEST-HammerCLI-Options-Normalizers-abstract.xml +2 -2
  122. data/test/reports/TEST-HammerCLI-Options-Normalizers-bool.xml +13 -13
  123. data/test/reports/TEST-HammerCLI-Options-Normalizers-datetime.xml +6 -6
  124. data/test/reports/TEST-HammerCLI-Options-Normalizers-enum.xml +5 -5
  125. data/test/reports/TEST-HammerCLI-Options-Normalizers-enumlist.xml +8 -8
  126. data/test/reports/TEST-HammerCLI-Options-Normalizers-json-input.xml +5 -5
  127. data/test/reports/TEST-HammerCLI-Options-Normalizers-key-value-list.xml +6 -26
  128. data/test/reports/TEST-HammerCLI-Options-Normalizers-list.xml +5 -5
  129. data/test/reports/TEST-HammerCLI-Options-Normalizers.xml +1 -1
  130. data/test/reports/TEST-HammerCLI-Options-OptionDefinition-context.xml +2 -2
  131. data/test/reports/TEST-HammerCLI-Options-OptionDefinition-formatters.xml +3 -3
  132. data/test/reports/TEST-HammerCLI-Options-OptionDefinition.xml +1 -1
  133. data/test/reports/TEST-HammerCLI-Output-Adapter-Abstract-error-messages.xml +5 -5
  134. data/test/reports/TEST-HammerCLI-Output-Adapter-Abstract-messages.xml +3 -3
  135. data/test/reports/TEST-HammerCLI-Output-Adapter-Abstract-test-data-for-field.xml +5 -5
  136. data/test/reports/TEST-HammerCLI-Output-Adapter-Abstract.xml +6 -6
  137. data/test/reports/TEST-HammerCLI-Output-Adapter-Base-print-collection-show-ids.xml +2 -2
  138. data/test/reports/TEST-HammerCLI-Output-Adapter-Base-print-collection.xml +11 -11
  139. data/test/reports/TEST-HammerCLI-Output-Adapter-Base.xml +1 -1
  140. data/test/reports/TEST-HammerCLI-Output-Adapter-CSValues-print-collection-formatters.xml +3 -3
  141. data/test/reports/TEST-HammerCLI-Output-Adapter-CSValues-print-collection-handle-fields-with-collections.xml +4 -4
  142. data/test/reports/TEST-HammerCLI-Output-Adapter-CSValues-print-collection-handle-fields-with-containers.xml +3 -3
  143. data/test/reports/TEST-HammerCLI-Output-Adapter-CSValues-print-collection-handle-ids.xml +3 -3
  144. data/test/reports/TEST-HammerCLI-Output-Adapter-CSValues-print-collection.xml +3 -3
  145. data/test/reports/TEST-HammerCLI-Output-Adapter-CSValues-print-message.xml +3 -3
  146. data/test/reports/TEST-HammerCLI-Output-Adapter-CSValues.xml +1 -1
  147. data/test/reports/TEST-HammerCLI-Output-Adapter-Table-print-collection-column-width.xml +5 -11
  148. data/test/reports/TEST-HammerCLI-Output-Adapter-Table-print-collection-formatters.xml +3 -3
  149. data/test/reports/TEST-HammerCLI-Output-Adapter-Table-print-collection-handle-ids.xml +3 -7
  150. data/test/reports/TEST-HammerCLI-Output-Adapter-Table-print-collection-sort-columns.xml +2 -2
  151. data/test/reports/TEST-HammerCLI-Output-Adapter-Table-print-collection.xml +3 -3
  152. data/test/reports/TEST-HammerCLI-Output-Adapter-Table.xml +1 -1
  153. data/test/reports/TEST-HammerCLI-Output-Definition-empty-.xml +3 -3
  154. data/test/reports/TEST-HammerCLI-Output-Definition.xml +3 -3
  155. data/test/reports/TEST-HammerCLI-Output-Dsl-collection.xml +4 -4
  156. data/test/reports/TEST-HammerCLI-Output-Dsl-custom-fields.xml +3 -3
  157. data/test/reports/TEST-HammerCLI-Output-Dsl-fields.xml +5 -5
  158. data/test/reports/TEST-HammerCLI-Output-Dsl-label.xml +4 -4
  159. data/test/reports/TEST-HammerCLI-Output-Dsl-path-definition.xml +4 -4
  160. data/test/reports/TEST-HammerCLI-Output-Dsl.xml +2 -2
  161. data/test/reports/TEST-HammerCLI-Output-FieldFilter.xml +4 -4
  162. data/test/reports/TEST-HammerCLI-Output-Formatters-BooleanFormatter.xml +3 -3
  163. data/test/reports/TEST-HammerCLI-Output-Formatters-ColorFormatter.xml +2 -2
  164. data/test/reports/TEST-HammerCLI-Output-Formatters-DateFormatter.xml +3 -3
  165. data/test/reports/TEST-HammerCLI-Output-Formatters-FieldFormatter.xml +4 -4
  166. data/test/reports/TEST-HammerCLI-Output-Formatters-FormatterContainer.xml +4 -4
  167. data/test/reports/TEST-HammerCLI-Output-Formatters-FormatterLibrary.xml +3 -3
  168. data/test/reports/TEST-HammerCLI-Output-Formatters-KeyValueFormatter.xml +4 -4
  169. data/test/reports/TEST-HammerCLI-Output-Formatters-ListFormatter.xml +4 -4
  170. data/test/reports/TEST-HammerCLI-Output-Formatters-LongTextFormatter.xml +4 -4
  171. data/test/reports/TEST-HammerCLI-Output-Output-adapters.xml +6 -6
  172. data/test/reports/TEST-HammerCLI-Output-Output-data.xml +5 -5
  173. data/test/reports/TEST-HammerCLI-Output-Output-formatters.xml +2 -2
  174. data/test/reports/TEST-HammerCLI-Output-Output-messages.xml +7 -7
  175. data/test/reports/TEST-HammerCLI-Output-Output.xml +1 -1
  176. data/test/reports/TEST-HammerCLI-Output-RecordCollection.xml +4 -4
  177. data/test/reports/TEST-HammerCLI-Settings-load-from-paths.xml +5 -5
  178. data/test/reports/TEST-HammerCLI-Settings.xml +10 -10
  179. data/test/reports/TEST-HammerCLI-ShellHistory-loading-old-history.xml +3 -3
  180. data/test/reports/TEST-HammerCLI-ShellHistory-saving-history.xml +5 -5
  181. data/test/reports/TEST-HammerCLI-ShellHistory.xml +1 -1
  182. data/test/reports/TEST-MiniTest-Spec.xml +1 -1
  183. data/test/reports/TEST-String-camelize.xml +3 -3
  184. data/test/reports/TEST-String-formatting.xml +6 -6
  185. data/test/reports/TEST-String-indent.xml +3 -3
  186. data/test/reports/{TEST-HammerCLI-interactive-.xml → TEST-String-interactive-.xml} +4 -4
  187. data/test/reports/TEST-String.xml +1 -1
  188. data/test/reports/TEST-constraints-HammerCLI-Validator-AllConstraint-exist-.xml +4 -4
  189. data/test/reports/TEST-constraints-HammerCLI-Validator-AllConstraint.xml +1 -1
  190. data/test/reports/TEST-constraints-HammerCLI-Validator-AnyConstraint-exist-.xml +4 -4
  191. data/test/reports/TEST-constraints-HammerCLI-Validator-AnyConstraint.xml +1 -1
  192. data/test/reports/TEST-constraints-HammerCLI-Validator-BaseConstraint-exist-.xml +2 -2
  193. data/test/reports/TEST-constraints-HammerCLI-Validator-BaseConstraint-rejected.xml +4 -4
  194. data/test/reports/TEST-constraints-HammerCLI-Validator-BaseConstraint-required.xml +4 -4
  195. data/test/reports/TEST-constraints-HammerCLI-Validator-BaseConstraint.xml +1 -1
  196. data/test/reports/TEST-constraints.xml +1 -1
  197. data/test/unit/apipie/option_definition_test.rb +9 -0
  198. data/test/unit/defaults_test.rb +84 -22
  199. data/test/unit/fixtures/defaults/defaults_dashed.yml +6 -0
  200. data/test/unit/options/normalizers_test.rb +46 -34
  201. data/test/unit/output/adapter/abstract_test.rb +4 -0
  202. data/test/unit/output/adapter/base_test.rb +4 -0
  203. data/test/unit/output/adapter/csv_test.rb +4 -0
  204. data/test/unit/output/adapter/json_test.rb +4 -0
  205. data/test/unit/output/adapter/table_test.rb +19 -3
  206. data/test/unit/output/adapter/yaml_test.rb +4 -0
  207. data/test/unit/output/record_collection_test.rb +26 -0
  208. data/test/unit/settings_test.rb +11 -1
  209. data/test/unit/validator_test.rb +111 -6
  210. metadata +192 -247
  211. data/test/reports/TEST-Fields-Label-display-.xml +0 -7
  212. data/test/reports/TEST-Fields-Label-display-blank-is-allowed.xml +0 -15
  213. data/test/reports/TEST-Fields-Label-display-blank-is-not-allowed.xml +0 -15
  214. data/test/reports/TEST-Fields-Label.xml +0 -7
  215. data/test/reports/TEST-HammerCLI-Apipie-Command-reload-apipie-cache.xml +0 -11
  216. data/test/reports/TEST-HammerCLI-Apipie-OptionBuilder-setting-referenced-resources.xml +0 -9
  217. data/test/reports/TEST-HammerCLI-Apipie-OptionDefinition-referenced-resource.xml +0 -13
  218. data/test/reports/TEST-HammerCLI-Apipie-OptionDefinition.xml +0 -7
  219. data/test/reports/TEST-HammerCLI-Defaults.xml +0 -19
  220. data/test/reports/TEST-HammerCLI-Options-Matcher.xml +0 -17
  221. data/test/reports/TEST-HammerCLI-Options-Normalizers-number.xml +0 -11
  222. data/test/reports/TEST-HammerCLI-Options-OptionDefinition-deprecated-options.xml +0 -11
  223. data/test/reports/TEST-HammerCLI-Output-Adapter-Json-print-collection-show-ids.xml +0 -9
  224. data/test/reports/TEST-HammerCLI-Output-Adapter-Json-print-collection.xml +0 -27
  225. data/test/reports/TEST-HammerCLI-Output-Adapter-Json-print-message.xml +0 -11
  226. data/test/reports/TEST-HammerCLI-Output-Adapter-Json.xml +0 -7
  227. data/test/reports/TEST-HammerCLI-Output-Adapter-Yaml-print-collection-show-ids.xml +0 -9
  228. data/test/reports/TEST-HammerCLI-Output-Adapter-Yaml-print-collection.xml +0 -27
  229. data/test/reports/TEST-HammerCLI-Output-Adapter-Yaml-print-message.xml +0 -11
  230. data/test/reports/TEST-HammerCLI-Output-Adapter-Yaml.xml +0 -7
  231. data/test/reports/TEST-HammerCLI-constant-path.xml +0 -15
  232. data/test/reports/TEST-HammerCLI.xml +0 -7
  233. data/test/reports/TEST-Logging-LogEvent-filtering.xml +0 -9
  234. data/test/reports/TEST-Logging-LogEvent.xml +0 -7
  235. data/test/reports/TEST-String-constantize.xml +0 -15
  236. data/test/reports/TEST-String-underscore.xml +0 -13
  237. data/test/reports/TEST-commands-defaults-add.xml +0 -21
  238. data/test/reports/TEST-commands-defaults-delete.xml +0 -11
  239. data/test/reports/TEST-commands-defaults-list.xml +0 -11
  240. data/test/reports/TEST-commands-defaults-providers.xml +0 -11
  241. data/test/reports/TEST-commands.xml +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 661dfeefa7e66df9be867455ff63a7c13b6f5d6d
4
- data.tar.gz: 52b417a7c11d721824b54881e9e5d1f9bb0e6463
3
+ metadata.gz: b39b8afbf9c00645ca1591288ec35f790efba222
4
+ data.tar.gz: b1b69c66682a9a1b38d2799f15c11da797990ca5
5
5
  SHA512:
6
- metadata.gz: 4a5b06fd20a0b605d63d41f2c2ed94a157e1672fed6e03a54dc3dff4d2d612c103f0d81c5606fe553a06b5e2b60be2b969fc5fb89e85fd1e0cb7b756c05d4ec6
7
- data.tar.gz: 3a2c18fe41a8d4ec4fbd584a52041b1cf148c6a2a59b6d9b1d958b083d52a482e6e754f753e7df39a37be1f47454716bcff2286059850ee9c36a0cfe01641d66
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
@@ -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.6.1 (2016-03-15)
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
@@ -23,32 +23,37 @@ module HammerCLI
23
23
  end
24
24
 
25
25
  def delete_default_from_conf(param)
26
- conf_file = YAML.load_file(path)
27
- conf_file[:defaults].delete(param)
28
- write_to_file conf_file
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.nil?
34
- defaults = YAML.load_file(path)
35
- defaults[:defaults] ||= {}
36
- default_options.each do |key, value|
37
- key = key.to_sym
38
- defaults[:defaults][key] = value ? {:value => value,} : {:provider => provider}
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
- write_to_file defaults
41
- defaults
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? || defaults_settings[option.to_sym].nil?
48
- if defaults_settings[option.to_sym][:provider]
49
- providers[defaults_settings[option.to_sym][:provider]].get_defaults(option.to_sym)
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[option.to_sym][:value]
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].defaults_settings && context[:defaults].defaults_settings[option_param_name.to_sym]
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
@@ -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
- result = {}
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
- pair_re = '([^,=]+)=([^,\[]+|\[[^\[\]]*\])'
36
- full_re = "^((%s)[,]?)+$" % pair_re
48
+ private
37
49
 
38
- unless Regexp.new(full_re).match(val)
39
- raise ArgumentError, _("value must be defined as a comma-separated list of key=value")
40
- end
50
+ def valid_key_value?(val)
51
+ Regexp.new(FULL_RE).match(val)
52
+ end
41
53
 
42
- val.scan(Regexp.new(pair_re)) do |key, value|
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
- return result
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={})
@@ -135,6 +135,11 @@ module HammerCLI::Output::Adapter
135
135
  end
136
136
  end
137
137
 
138
+ def initialize(context={}, formatters={})
139
+ super
140
+ @paginate_by_default = false
141
+ end
142
+
138
143
  def tags
139
144
  [:flat]
140
145
  end
@@ -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
 
@@ -72,6 +72,8 @@ module HammerCLI
72
72
  h.merge!(other_h) do |key, old_val, new_val|
73
73
  if old_val.is_a? Hash and new_val.is_a? Hash
74
74
  deep_merge!(old_val, new_val)
75
+ elsif old_val.is_a? Array and new_val.is_a? Array
76
+ old_val += new_val
75
77
  else
76
78
  new_val
77
79
  end
@@ -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
- all(to_check)
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
@@ -1,5 +1,5 @@
1
1
  module HammerCLI
2
2
  def self.version
3
- @version ||= Gem::Version.new '0.6.1'
3
+ @version ||= Gem::Version.new '0.7.0'
4
4
  end
5
5
  end
Binary file