hammer_cli 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/hammer +4 -9
- data/config/cli_config.template.yml +12 -6
- data/doc/creating_commands.md +38 -0
- data/doc/i18n.md +33 -2
- data/doc/option_normalizers.md +2 -0
- data/doc/release_notes.md +18 -0
- data/lib/hammer_cli/abstract.rb +7 -2
- data/lib/hammer_cli/apipie/option_builder.rb +1 -1
- data/lib/hammer_cli/ca_cert_fetcher.rb +8 -8
- data/lib/hammer_cli/clamp.rb +9 -9
- data/lib/hammer_cli/context.rb +2 -1
- data/lib/hammer_cli/defaults.rb +12 -14
- data/lib/hammer_cli/defaults_commands.rb +2 -2
- data/lib/hammer_cli/exception_handler.rb +1 -1
- data/lib/hammer_cli/help/builder.rb +2 -1
- data/lib/hammer_cli/i18n/find_task.rb +41 -0
- data/lib/hammer_cli/i18n.rb +4 -0
- data/lib/hammer_cli/logger.rb +1 -1
- data/lib/hammer_cli/main.rb +12 -11
- data/lib/hammer_cli/modules.rb +5 -8
- data/lib/hammer_cli/options/normalizers.rb +15 -11
- data/lib/hammer_cli/options/option_collector.rb +17 -3
- data/lib/hammer_cli/options/option_definition.rb +36 -21
- data/lib/hammer_cli/output/adapter/csv.rb +1 -1
- data/lib/hammer_cli/output/adapter/table.rb +8 -6
- data/lib/hammer_cli/settings.rb +1 -6
- data/lib/hammer_cli/shell.rb +2 -2
- data/lib/hammer_cli/ssloptions.rb +5 -5
- data/lib/hammer_cli/subcommand.rb +51 -26
- data/lib/hammer_cli/testing/command_assertions.rb +2 -2
- data/lib/hammer_cli/testing/messages.rb +54 -0
- data/lib/hammer_cli/validator.rb +9 -9
- data/lib/hammer_cli/version.rb +1 -1
- data/locale/ca/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/de/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/en/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/en_GB/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/es/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/fr/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/it/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/ja/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/ko/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/pt_BR/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/ru/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/zh_CN/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/zh_TW/LC_MESSAGES/hammer-cli.mo +0 -0
- data/man/hammer.1.gz +0 -0
- data/test/functional/defaults_test.rb +3 -12
- data/test/functional/help_test.rb +1 -1
- data/test/functional/nil_values_test.rb +75 -0
- data/test/functional/test_helper.rb +10 -0
- data/test/reports/TEST-Fields-ContainerField-display-.xml +7 -0
- data/test/reports/TEST-Fields-ContainerField-display-blank-is-allowed.xml +15 -0
- data/test/reports/TEST-Fields-ContainerField-display-blank-is-not-allowed.xml +15 -0
- data/test/reports/TEST-Fields-ContainerField.xml +7 -0
- data/test/reports/TEST-Fields-Field-display-.xml +7 -0
- data/test/reports/TEST-Fields-Field-display-blank-is-allowed.xml +11 -0
- data/test/reports/TEST-Fields-Field-display-blank-is-not-allowed.xml +11 -0
- data/test/reports/TEST-Fields-Field-hide-blank-.xml +11 -0
- data/test/reports/TEST-Fields-Field-parameters.xml +9 -0
- data/test/reports/TEST-Fields-Field.xml +13 -0
- data/test/reports/TEST-HammerCLI-AbstractCommand-build-options.xml +15 -0
- data/test/reports/TEST-HammerCLI-AbstractCommand-exception-handler.xml +13 -0
- data/test/reports/TEST-HammerCLI-AbstractCommand-logging.xml +21 -0
- data/test/reports/TEST-HammerCLI-AbstractCommand-option-builder.xml +11 -0
- data/test/reports/TEST-HammerCLI-AbstractCommand-options.xml +11 -0
- data/test/reports/TEST-HammerCLI-AbstractCommand-output.xml +19 -0
- data/test/reports/TEST-HammerCLI-AbstractCommand-subcommand-behavior-remove-subcommand.xml +11 -0
- data/test/reports/TEST-HammerCLI-AbstractCommand-subcommand-behavior-subcommand-.xml +13 -0
- data/test/reports/TEST-HammerCLI-AbstractCommand-subcommand-behavior-subcommand.xml +11 -0
- data/test/reports/TEST-HammerCLI-AbstractCommand-subcommand-behavior.xml +7 -0
- data/test/reports/TEST-HammerCLI-AbstractCommand.xml +11 -0
- data/test/reports/TEST-HammerCLI-Apipie-Command-options.xml +11 -0
- data/test/reports/TEST-HammerCLI-Apipie-Command-resource-defined.xml +9 -0
- data/test/reports/TEST-HammerCLI-Apipie-Command-setting-resources.xml +19 -0
- data/test/reports/TEST-HammerCLI-Apipie-Command.xml +9 -0
- data/test/reports/TEST-HammerCLI-Apipie-OptionBuilder-aliasing-resources.xml +13 -0
- data/test/reports/TEST-HammerCLI-Apipie-OptionBuilder-filtering-options.xml +15 -0
- data/test/reports/TEST-HammerCLI-Apipie-OptionBuilder-required-options.xml +11 -0
- data/test/reports/TEST-HammerCLI-Apipie-OptionBuilder-setting-correct-normalizers.xml +9 -0
- data/test/reports/TEST-HammerCLI-Apipie-OptionBuilder-with-hash-params.xml +11 -0
- data/test/reports/TEST-HammerCLI-Apipie-OptionBuilder-with-one-simple-param.xml +15 -0
- data/test/reports/TEST-HammerCLI-Apipie-OptionBuilder.xml +7 -0
- data/test/reports/TEST-HammerCLI-Completer-command-completion.xml +29 -0
- data/test/reports/TEST-HammerCLI-Completer-option-value-completion.xml +17 -0
- data/test/reports/TEST-HammerCLI-Completer-subcommand-completion.xml +19 -0
- data/test/reports/TEST-HammerCLI-Completer.xml +7 -0
- data/test/reports/TEST-HammerCLI-CompleterLine-line-complete.xml +25 -0
- data/test/reports/TEST-HammerCLI-CompleterLine-splitting-words.xml +29 -0
- data/test/reports/TEST-HammerCLI-CompleterLine.xml +7 -0
- data/test/reports/TEST-HammerCLI-CompleterWord-complete-.xml +23 -0
- data/test/reports/TEST-HammerCLI-CompleterWord-quote.xml +15 -0
- data/test/reports/TEST-HammerCLI-CompleterWord-quoted-.xml +13 -0
- data/test/reports/TEST-HammerCLI-CompleterWord.xml +7 -0
- data/test/reports/TEST-HammerCLI-Connection.xml +21 -0
- data/test/reports/TEST-HammerCLI-ExceptionHandler.xml +21 -0
- data/test/reports/TEST-HammerCLI-I18n.xml +11 -0
- data/test/reports/TEST-HammerCLI-MainCommand-loading-context-password.xml +11 -0
- data/test/reports/TEST-HammerCLI-MainCommand-loading-context-username.xml +11 -0
- data/test/reports/TEST-HammerCLI-MainCommand-loading-context-verbose.xml +9 -0
- data/test/reports/TEST-HammerCLI-MainCommand-loading-context.xml +7 -0
- data/test/reports/TEST-HammerCLI-MainCommand.xml +7 -0
- data/test/reports/TEST-HammerCLI-Modules-find-by-name.xml +13 -0
- data/test/reports/TEST-HammerCLI-Modules-load-a-module-module-not-found.xml +13 -0
- data/test/reports/TEST-HammerCLI-Modules-load-a-module-module-runtime-exception.xml +13 -0
- data/test/reports/TEST-HammerCLI-Modules-load-a-module-success.xml +15 -0
- data/test/reports/TEST-HammerCLI-Modules-load-a-module.xml +7 -0
- data/test/reports/TEST-HammerCLI-Modules-load-all-modules.xml +9 -0
- data/test/reports/TEST-HammerCLI-Modules-names.xml +13 -0
- data/test/reports/TEST-HammerCLI-Modules.xml +7 -0
- data/test/reports/TEST-HammerCLI-OptionBuilderContainer.0.xml +7 -0
- data/test/reports/TEST-HammerCLI-OptionBuilderContainer.xml +11 -0
- data/test/reports/TEST-HammerCLI-Options-Normalizers-abstract.xml +9 -0
- data/test/reports/TEST-HammerCLI-Options-Normalizers-bool.xml +31 -0
- data/test/reports/TEST-HammerCLI-Options-Normalizers-datetime.xml +17 -0
- data/test/reports/TEST-HammerCLI-Options-Normalizers-enum.xml +15 -0
- data/test/reports/TEST-HammerCLI-Options-Normalizers-enumlist.xml +21 -0
- data/test/reports/TEST-HammerCLI-Options-Normalizers-json-input.xml +15 -0
- data/test/reports/TEST-HammerCLI-Options-Normalizers-key-value-list.xml +17 -0
- data/test/reports/TEST-HammerCLI-Options-Normalizers-list.xml +15 -0
- data/test/reports/TEST-HammerCLI-Options-Normalizers.xml +7 -0
- data/test/reports/TEST-HammerCLI-Options-OptionDefinition-context.xml +9 -0
- data/test/reports/TEST-HammerCLI-Options-OptionDefinition-formatters.xml +11 -0
- data/test/reports/TEST-HammerCLI-Options-OptionDefinition.xml +7 -0
- data/test/reports/TEST-HammerCLI-Output-Adapter-Abstract-error-messages.xml +15 -0
- data/test/reports/TEST-HammerCLI-Output-Adapter-Abstract-messages.xml +11 -0
- data/test/reports/TEST-HammerCLI-Output-Adapter-Abstract-test-data-for-field.xml +15 -0
- data/test/reports/TEST-HammerCLI-Output-Adapter-Abstract.xml +17 -0
- data/test/reports/TEST-HammerCLI-Output-Adapter-Base-print-collection-show-ids.xml +9 -0
- data/test/reports/TEST-HammerCLI-Output-Adapter-Base-print-collection.xml +27 -0
- data/test/reports/TEST-HammerCLI-Output-Adapter-Base.xml +7 -0
- data/test/reports/TEST-HammerCLI-Output-Adapter-CSValues-print-collection-formatters.xml +11 -0
- data/test/reports/TEST-HammerCLI-Output-Adapter-CSValues-print-collection-handle-fields-with-collections.xml +13 -0
- data/test/reports/TEST-HammerCLI-Output-Adapter-CSValues-print-collection-handle-fields-with-containers.xml +11 -0
- data/test/reports/TEST-HammerCLI-Output-Adapter-CSValues-print-collection-handle-ids.xml +11 -0
- data/test/reports/TEST-HammerCLI-Output-Adapter-CSValues-print-collection.xml +11 -0
- data/test/reports/TEST-HammerCLI-Output-Adapter-CSValues-print-message.xml +11 -0
- data/test/reports/TEST-HammerCLI-Output-Adapter-CSValues.xml +7 -0
- data/test/reports/TEST-HammerCLI-Output-Adapter-Table-print-collection-column-width.xml +15 -0
- data/test/reports/TEST-HammerCLI-Output-Adapter-Table-print-collection-formatters.xml +11 -0
- data/test/reports/TEST-HammerCLI-Output-Adapter-Table-print-collection-handle-ids.xml +11 -0
- data/test/reports/TEST-HammerCLI-Output-Adapter-Table-print-collection-sort-columns.xml +9 -0
- data/test/reports/TEST-HammerCLI-Output-Adapter-Table-print-collection.xml +11 -0
- data/test/reports/TEST-HammerCLI-Output-Adapter-Table.xml +7 -0
- data/test/reports/TEST-HammerCLI-Output-Definition-empty-.xml +11 -0
- data/test/reports/TEST-HammerCLI-Output-Definition.xml +11 -0
- data/test/reports/TEST-HammerCLI-Output-Dsl-collection.xml +13 -0
- data/test/reports/TEST-HammerCLI-Output-Dsl-custom-fields.xml +11 -0
- data/test/reports/TEST-HammerCLI-Output-Dsl-fields.xml +15 -0
- data/test/reports/TEST-HammerCLI-Output-Dsl-label.xml +13 -0
- data/test/reports/TEST-HammerCLI-Output-Dsl-path-definition.xml +13 -0
- data/test/reports/TEST-HammerCLI-Output-Dsl.xml +9 -0
- data/test/reports/TEST-HammerCLI-Output-FieldFilter.xml +13 -0
- data/test/reports/TEST-HammerCLI-Output-Formatters-BooleanFormatter.xml +11 -0
- data/test/reports/TEST-HammerCLI-Output-Formatters-ColorFormatter.xml +9 -0
- data/test/reports/TEST-HammerCLI-Output-Formatters-DateFormatter.xml +11 -0
- data/test/reports/TEST-HammerCLI-Output-Formatters-FieldFormatter.xml +13 -0
- data/test/reports/TEST-HammerCLI-Output-Formatters-FormatterContainer.xml +13 -0
- data/test/reports/TEST-HammerCLI-Output-Formatters-FormatterLibrary.xml +11 -0
- data/test/reports/TEST-HammerCLI-Output-Formatters-KeyValueFormatter.xml +13 -0
- data/test/reports/TEST-HammerCLI-Output-Formatters-ListFormatter.xml +13 -0
- data/test/reports/TEST-HammerCLI-Output-Formatters-LongTextFormatter.xml +13 -0
- data/test/reports/TEST-HammerCLI-Output-Output-adapters.xml +17 -0
- data/test/reports/TEST-HammerCLI-Output-Output-data.xml +15 -0
- data/test/reports/TEST-HammerCLI-Output-Output-formatters.xml +9 -0
- data/test/reports/TEST-HammerCLI-Output-Output-messages.xml +19 -0
- data/test/reports/TEST-HammerCLI-Output-Output.xml +7 -0
- data/test/reports/TEST-HammerCLI-Output-RecordCollection.xml +13 -0
- data/test/reports/TEST-HammerCLI-Settings-load-from-paths.xml +15 -0
- data/test/reports/TEST-HammerCLI-Settings.xml +25 -0
- data/test/reports/TEST-HammerCLI-ShellHistory-loading-old-history.xml +11 -0
- data/test/reports/TEST-HammerCLI-ShellHistory-saving-history.xml +15 -0
- data/test/reports/TEST-HammerCLI-ShellHistory.xml +7 -0
- data/test/reports/TEST-MiniTest-Spec.xml +7 -0
- data/test/reports/TEST-String-camelize.xml +11 -0
- data/test/reports/TEST-String-formatting.xml +17 -0
- data/test/reports/TEST-String-indent.xml +11 -0
- data/test/reports/TEST-String-interactive-.xml +13 -0
- data/test/reports/TEST-String.xml +7 -0
- data/test/reports/TEST-constraints-HammerCLI-Validator-AllConstraint-exist-.xml +13 -0
- data/test/reports/TEST-constraints-HammerCLI-Validator-AllConstraint.xml +7 -0
- data/test/reports/TEST-constraints-HammerCLI-Validator-AnyConstraint-exist-.xml +13 -0
- data/test/reports/TEST-constraints-HammerCLI-Validator-AnyConstraint.xml +7 -0
- data/test/reports/TEST-constraints-HammerCLI-Validator-BaseConstraint-exist-.xml +9 -0
- data/test/reports/TEST-constraints-HammerCLI-Validator-BaseConstraint-rejected.xml +13 -0
- data/test/reports/TEST-constraints-HammerCLI-Validator-BaseConstraint-required.xml +13 -0
- data/test/reports/TEST-constraints-HammerCLI-Validator-BaseConstraint.xml +7 -0
- data/test/reports/TEST-constraints.xml +7 -0
- data/test/unit/abstract_test.rb +10 -1
- data/test/unit/apipie/option_builder_test.rb +6 -0
- data/test/unit/defaults_test.rb +12 -5
- data/test/unit/exception_handler_test.rb +1 -1
- data/test/unit/fixtures/apipie/documented.json +10 -1
- data/test/unit/help/builder_test.rb +16 -1
- data/test/unit/messages_test.rb +7 -0
- data/test/unit/modules_test.rb +4 -15
- data/test/unit/options/normalizers_test.rb +21 -1
- data/test/unit/options/option_collector_test.rb +10 -4
- data/test/unit/output/adapter/csv_test.rb +29 -0
- data/test/unit/output/adapter/table_test.rb +27 -0
- data/test/unit/validator_test.rb +4 -4
- metadata +353 -53
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0aa589ebe2589ead222c05b6b8a1de324f3efdb5
|
|
4
|
+
data.tar.gz: 1068b381dbe8685c2a1d7bc0168513f5e48ccce9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c7153a9ebaab813ef8ea1061461efd60c1e357f5445187762203aed5055bb1e38eac86d787f4bec013e5cc78e84afd40fbb3ac81cef8a3b1844732356a7f864f
|
|
7
|
+
data.tar.gz: ff4d24d0067d7e500ee573bfb82531637c67f557d1ef9745d4b2587ed31e9edbac0aa6d47eb79778e97658627495f3327b5cac0626d56ea04dfd8a27c7c1b8ba
|
data/bin/hammer
CHANGED
|
@@ -29,6 +29,7 @@ class PreParser < Clamp::Command
|
|
|
29
29
|
option ["--show-ids"], :flag, "Show ids of associated resources"
|
|
30
30
|
option ["--csv"], :flag, "Output as CSV (same as --output=csv)"
|
|
31
31
|
option ["--output"], "ADAPTER", "Set output format"
|
|
32
|
+
option ["--no-headers"], :flag, "Hide headers from output"
|
|
32
33
|
option ["--csv-separator"], "SEPARATOR", "Character to separate the values"
|
|
33
34
|
option ["--autocomplete"], "LINE", "Get list of possible endings"
|
|
34
35
|
option ["--verify-ssl"], "VERIFY_SSL", "Configure SSL verification of remote system" do |value|
|
|
@@ -52,15 +53,8 @@ end
|
|
|
52
53
|
# load user's settings
|
|
53
54
|
require 'hammer_cli/settings'
|
|
54
55
|
|
|
55
|
-
|
|
56
|
-
HammerCLI::Settings.load_from_paths
|
|
57
|
-
if HammerCLI::Settings.path_history.empty?
|
|
58
|
-
CFG_PATH = ['~/.hammer/', '/etc/hammer/', "#{::RbConfig::CONFIG['sysconfdir']}/hammer/"].uniq
|
|
59
|
-
HammerCLI::Settings.load_from_paths CFG_PATH
|
|
60
|
-
else
|
|
61
|
-
warn _("Warning: Legacy config paths detected, move the following files")
|
|
62
|
-
HammerCLI::Settings.path_history.each { |p| warn " #{p} -> #{p.gsub('hammer.modules.d', 'cli.modules.d').gsub('foreman/', 'hammer/')}"}
|
|
63
|
-
end
|
|
56
|
+
CFG_PATH = ['~/.hammer/', '/etc/hammer/', "#{::RbConfig::CONFIG['sysconfdir']}/hammer/"].uniq
|
|
57
|
+
HammerCLI::Settings.load_from_paths CFG_PATH
|
|
64
58
|
|
|
65
59
|
CFG_PATH_LOCAL = ['./config/']
|
|
66
60
|
|
|
@@ -86,6 +80,7 @@ HammerCLI::Settings.load({
|
|
|
86
80
|
:host => preparser.server,
|
|
87
81
|
:interactive => preparser.interactive,
|
|
88
82
|
:verbose => preparser.verbose? || preparser.debug?,
|
|
83
|
+
:no_headers => preparser.no_headers?,
|
|
89
84
|
:reload_cache => preparser.reload_cache?,
|
|
90
85
|
:verify_ssl => preparser.verify_ssl,
|
|
91
86
|
:ssl_ca_file => preparser.ssl_ca_file,
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
:history_file: '~/.hammer/history'
|
|
9
9
|
# Mark translated strings with X characters (for developers)
|
|
10
10
|
#:mark_translated: false
|
|
11
|
-
|
|
11
|
+
# Hide headers from output of list actions
|
|
12
|
+
# :no_headers: true
|
|
12
13
|
|
|
13
14
|
# Enable/disable color output of logger in Clamp commands
|
|
14
15
|
:watch_plain: false
|
|
@@ -34,23 +35,28 @@
|
|
|
34
35
|
|
|
35
36
|
# SSL auth options
|
|
36
37
|
#:ssl:
|
|
37
|
-
# Path to a
|
|
38
|
+
# Path to a CA file in PEM format, mutually exclusive with :ssl_ca_path:
|
|
38
39
|
#:ssl_ca_file: '/path/to/ca_certificate.pem'
|
|
39
40
|
|
|
40
|
-
# Path to a direcotry with
|
|
41
|
+
# Path to a direcotry with CA files, mutually exclusive with :ssl_ca_file:
|
|
42
|
+
# The directory should contain one certificate per file in PEM format, with a file name of the form hash.N
|
|
43
|
+
# The hash can be obtained via the -hash option of the openssl x509 command. See the OpenSSL documentation
|
|
44
|
+
# for more information.
|
|
41
45
|
#:ssl_ca_path: '/path/to/ca'
|
|
42
46
|
|
|
43
47
|
# Turn SSL verification on/off
|
|
44
48
|
#:verify_ssl: true
|
|
45
49
|
|
|
46
|
-
# Path to a client certificate
|
|
50
|
+
# Path to a client certificate, DER- or PEM-encoded certificates are supported
|
|
47
51
|
#:ssl_client_cert: '/path/to/cert.crt'
|
|
48
52
|
|
|
49
53
|
# Path to a client key
|
|
50
54
|
#:ssl_client_key: '/path/to/cert.key'
|
|
51
55
|
|
|
52
|
-
# Enable standard authentication in addition to client certificate authentication
|
|
56
|
+
# Enable standard authentication in addition to client certificate authentication.
|
|
57
|
+
# Switch to false if you want to rely on certificates only.
|
|
53
58
|
#:ssl_with_basic_auth: true
|
|
54
59
|
|
|
55
|
-
#
|
|
60
|
+
# Local CA cert store path where hammer stores certificates fetched from the server.
|
|
61
|
+
# Certs from the local storage are used only when neither :ssl_ca_file: nor :ssl_ca_path: is cofigured.
|
|
56
62
|
#:local_ca_store_path: '~/.hammer/certs'
|
data/doc/creating_commands.md
CHANGED
|
@@ -129,6 +129,22 @@ $ hammer hello --name 'Foreman'
|
|
|
129
129
|
Hello Foreman!
|
|
130
130
|
```
|
|
131
131
|
|
|
132
|
+
#### Nil values ####
|
|
133
|
+
To unset some option (i.e. to set it to nil value) use preset value `NIL`:
|
|
134
|
+
```
|
|
135
|
+
$ hammer hello --name NIL
|
|
136
|
+
Hello World!
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
When the `NIL` value collides with a real value being used it can be redefined using
|
|
140
|
+
environment variable `HAMMER_NIL`:
|
|
141
|
+
```
|
|
142
|
+
$ HAMMER_NIL=NULL hammer hello --name NIL
|
|
143
|
+
Hello NIL!
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Note that the normalizers are not called for a NIL values even when defined for the option.
|
|
147
|
+
|
|
132
148
|
#### Deprecated options
|
|
133
149
|
To mark an option as deprecated use the `:deprecated` option as follows:
|
|
134
150
|
```ruby
|
|
@@ -226,6 +242,28 @@ option "--attributes", "ATTRIBUTES", "Values of various attributes",
|
|
|
226
242
|
```
|
|
227
243
|
`--attributes="material=unoptanium,thickness=3"` -> `{'material' => 'unoptanium', 'thickness' => '3'}`
|
|
228
244
|
|
|
245
|
+
### Advanced option evaluation
|
|
246
|
+
|
|
247
|
+
Sometimes it is necessary to tune the option values based on other parameters given on CLI.
|
|
248
|
+
An example could be setting default values based on other options, values lookup in a DB, etc.
|
|
249
|
+
The right place for this are `OptionSources`. Abstract Hammer command uses two default option sources -
|
|
250
|
+
`HammerCLI::Options::Sources::CommandLine` responsible for intial population of the options,
|
|
251
|
+
`HammerCLI::Options::Sources::SavedDefaults` adding defaults managed by the `defaults` command.
|
|
252
|
+
|
|
253
|
+
By overriding `option_sources` method in a command it is possible to add custom option sources
|
|
254
|
+
for various tasks to the list. The option sources are evaluated one by one each being given output
|
|
255
|
+
of the previous one as its input so the order in which the sources are listed matters.
|
|
256
|
+
|
|
257
|
+
Option sources are collected only once per command call. The collection is triggered by first call
|
|
258
|
+
to the `options` or `all_options` method, but at latest right after the option validation
|
|
259
|
+
(before the command's `execute` method is invoked). The order is as follows:
|
|
260
|
+
1. parse
|
|
261
|
+
1. option normalization
|
|
262
|
+
1. option validation (run against normalized raw options as given on CLI)
|
|
263
|
+
1. option sources execution
|
|
264
|
+
1. `execute` invocation
|
|
265
|
+
|
|
266
|
+
|
|
229
267
|
### Adding subcommands
|
|
230
268
|
Commands in the CLI can be structured into a tree of parent commands (nodes) and subcommands (leaves).
|
|
231
269
|
Neither the number of subcommands nor the nesting is limited. Please note that no parent command
|
data/doc/i18n.md
CHANGED
|
@@ -46,7 +46,6 @@ HammerCLI::I18n.add_domain(HammerCLIAwesomePlugin::I18n::LocaleDomain.new)
|
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
Then you have to export strings, translate them and place the files in a directory structure.
|
|
49
|
-
Inspiration on how to export the translations can be found in hammer's [Rakefile](../Rakefile).
|
|
50
49
|
|
|
51
50
|
Typical directory structure for translation files look like this:
|
|
52
51
|
```
|
|
@@ -62,6 +61,29 @@ locale
|
|
|
62
61
|
└── hammer-cli-awesome.pot
|
|
63
62
|
```
|
|
64
63
|
|
|
64
|
+
You can re-use Rake tasks and Makefile targets for extracting translations and integration with transifex that hammer provides.
|
|
65
|
+
To do that, add following lines to the plugin's Rakefile:
|
|
66
|
+
```ruby
|
|
67
|
+
require "hammer_cli_awesome/version"
|
|
68
|
+
require "hammer_cli_awesome/i18n"
|
|
69
|
+
require "hammer_cli/i18n/find_task"
|
|
70
|
+
HammerCLI::I18n::FindTask.define(HammerCLIAwesome::I18n::LocaleDomain.new, HammerCLIAwesome.version)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
and create `locale/Makefile` with following content:
|
|
74
|
+
```make
|
|
75
|
+
DOMAIN = hammer-cli-awesome
|
|
76
|
+
VERSION = $(shell bundle exec ruby -e 'require "rubygems"; spec = Gem::Specification::load("../hammer_cli_awesome.gemspec"); puts spec.version')
|
|
77
|
+
MAIN_MAKEFILE = $(shell bundle exec ruby -e 'require "hammer_cli"; puts HammerCLI::I18n.main_makefile')
|
|
78
|
+
|
|
79
|
+
include $(MAIN_MAKEFILE)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Make sure you have a project created in [transifex](www.transifex.com) and correct configuration stored in your plugins repository ([example config file](../.tx/config)).
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
Calling `make -C ./locale tx-update` will then extract new strings, update `.po` and `.mo` files and commit the changes.
|
|
86
|
+
|
|
65
87
|
|
|
66
88
|
### Translation tips
|
|
67
89
|
|
|
@@ -96,5 +118,14 @@ puts _("TODO:") +
|
|
|
96
118
|
```
|
|
97
119
|
|
|
98
120
|
|
|
99
|
-
4)
|
|
121
|
+
4) It's recommended to use punctuation at the end of sentences.
|
|
122
|
+
```ruby
|
|
123
|
+
# CORRECT
|
|
124
|
+
puts _("Hello %s") % name
|
|
125
|
+
# RECOMMENDED
|
|
126
|
+
puts _("Hello %s.") % name
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
5) Try setting `:mark_translated: true` to identify gaps in your translations.
|
|
100
131
|
This will wrap all translated strings with angle brackets '>message<'.
|
data/doc/option_normalizers.md
CHANGED
data/doc/release_notes.md
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
Release notes
|
|
2
2
|
=============
|
|
3
3
|
|
|
4
|
+
### 0.12.0 (2018-02-19)
|
|
5
|
+
* Tests for message formats ([PR #266](https://github.com/theforeman/hammer-cli/pull/266)) ([#7451](http://projects.theforeman.org/issues/7451))
|
|
6
|
+
* Pin clamp version to < 1.2.0 ([#22554](http://projects.theforeman.org/issues/22554))
|
|
7
|
+
* Fix "unknown version" message ([#7451](http://projects.theforeman.org/issues/7451))
|
|
8
|
+
* Remove legacy Gemfile code for Ruby < 2.0 ([#22549](http://projects.theforeman.org/issues/22549))
|
|
9
|
+
* Allow hiding headers from output of list actions ([PR #253](https://github.com/theforeman/hammer-cli/pull/253)) ([#20978](http://projects.theforeman.org/issues/20978))
|
|
10
|
+
* Review whitespace in extracted strings ([#7451](http://projects.theforeman.org/issues/7451))
|
|
11
|
+
* Matches user prefix in output messages for CA certs ([#21707](http://projects.theforeman.org/issues/21707))
|
|
12
|
+
* Make option sources overridable ([#21768](http://projects.theforeman.org/issues/21768))
|
|
13
|
+
* Allow empty parameters in hammer ([PR #260](https://github.com/theforeman/hammer-cli/pull/260)) ([#17252](http://projects.theforeman.org/issues/17252))
|
|
14
|
+
* Shareable locale Makefile and Rakefile definitions ([PR #249](https://github.com/theforeman/hammer-cli/pull/249)) ([#20513](http://projects.theforeman.org/issues/20513))
|
|
15
|
+
* Support for deprecating commands ([#20804](http://projects.theforeman.org/issues/20804))
|
|
16
|
+
* Remove legacy config code ([#20611](http://projects.theforeman.org/issues/20611))
|
|
17
|
+
* Number normalizers for Integer params ([#21013](http://projects.theforeman.org/issues/21013))
|
|
18
|
+
* More detailed description of ssl options ([PR #248](https://github.com/theforeman/hammer-cli/pull/248)) ([#12401](http://projects.theforeman.org/issues/12401))
|
|
19
|
+
* Consistant capitalization in hammer help ([#19511](http://projects.theforeman.org/issues/19511))
|
|
20
|
+
* Saving defaults from hammer shell ([PR #244](https://github.com/theforeman/hammer-cli/pull/244)) ([#19676](http://projects.theforeman.org/issues/19676))
|
|
21
|
+
|
|
4
22
|
### 0.11.0 (2017-08-01)
|
|
5
23
|
* Add full-help command ([#20181](http://projects.theforeman.org/issues/20181))
|
|
6
24
|
* Replace CSV parser in List Normalizer ([#17135](http://projects.theforeman.org/issues/17135))
|
data/lib/hammer_cli/abstract.rb
CHANGED
|
@@ -240,10 +240,15 @@ module HammerCLI
|
|
|
240
240
|
end
|
|
241
241
|
|
|
242
242
|
def option_collector
|
|
243
|
-
@option_collector ||= HammerCLI::Options::OptionCollector.new(self.class.recognised_options,
|
|
243
|
+
@option_collector ||= HammerCLI::Options::OptionCollector.new(self.class.recognised_options, option_sources)
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
def option_sources
|
|
248
|
+
[
|
|
244
249
|
HammerCLI::Options::Sources::CommandLine.new(self),
|
|
245
250
|
HammerCLI::Options::Sources::SavedDefaults.new(context[:defaults], logger)
|
|
246
|
-
]
|
|
251
|
+
]
|
|
247
252
|
end
|
|
248
253
|
|
|
249
254
|
private
|
|
@@ -71,7 +71,7 @@ module HammerCLI::Apipie
|
|
|
71
71
|
elsif param.validator =~ /Must be one of: (.*)\./
|
|
72
72
|
allowed = $1.split(/,\ ?/).map { |val| val.gsub(/<[^>]*>/i,'') }
|
|
73
73
|
opts[:format] = HammerCLI::Options::Normalizers::Enum.new(allowed)
|
|
74
|
-
elsif param.expected_type.to_s == '
|
|
74
|
+
elsif param.expected_type.to_s == 'numeric' || param.validator =~ /Number/i || param.validator =~ /Integer/i
|
|
75
75
|
opts[:format] = HammerCLI::Options::Normalizers::Number.new
|
|
76
76
|
end
|
|
77
77
|
opts[:attribute_name] = HammerCLI.option_accessor_name(param.name)
|
|
@@ -4,7 +4,7 @@ module HammerCLI
|
|
|
4
4
|
def fetch_ca_cert(service_uri, ca_store_path)
|
|
5
5
|
begin
|
|
6
6
|
uri = URI.parse(service_uri)
|
|
7
|
-
raise URI::InvalidURIError.new(_("Unable to find hostname in
|
|
7
|
+
raise URI::InvalidURIError.new(_("Unable to find hostname in %s.") % service_uri) if uri.host.nil?
|
|
8
8
|
raise URI::InvalidURIError.new(scheme_error(uri)) unless uri.scheme == 'https'
|
|
9
9
|
ca_cert_manager = HammerCLI::CACertManager.new(ca_store_path)
|
|
10
10
|
raw_cert = HammerCLI::CertDownloader.new.download(uri)
|
|
@@ -17,7 +17,7 @@ module HammerCLI
|
|
|
17
17
|
deb_update_cmd = "update-ca-certificates"
|
|
18
18
|
cert_file = ca_cert_manager.cert_file_name(uri)
|
|
19
19
|
|
|
20
|
-
puts _("CA certificate for %{uri} was stored to %{file}") % {:uri => service_uri, :file => cert_file}
|
|
20
|
+
puts _("CA certificate for %{uri} was stored to %{file}.") % {:uri => service_uri, :file => cert_file}
|
|
21
21
|
puts _("Now hammer can use the downloaded certificate to verify SSL connection to the server.")
|
|
22
22
|
puts _("It will be used automatically when ssl_ca_path and ssl_ca_file options are not set.")
|
|
23
23
|
puts
|
|
@@ -31,12 +31,12 @@ module HammerCLI
|
|
|
31
31
|
|
|
32
32
|
if File.directory?(rh_install_path)
|
|
33
33
|
puts cert_install_msg
|
|
34
|
-
puts "
|
|
35
|
-
puts "
|
|
34
|
+
puts " # install #{cert_file} #{rh_install_path}"
|
|
35
|
+
puts " # #{rh_update_cmd}"
|
|
36
36
|
elsif File.directory?(deb_install_path)
|
|
37
37
|
puts cert_install_msg
|
|
38
|
-
puts "
|
|
39
|
-
puts "
|
|
38
|
+
puts " # install #{cert_file} #{deb_install_path}"
|
|
39
|
+
puts " # #{deb_update_cmd}"
|
|
40
40
|
end
|
|
41
41
|
puts
|
|
42
42
|
return HammerCLI::EX_OK
|
|
@@ -52,7 +52,7 @@ module HammerCLI
|
|
|
52
52
|
$stderr.puts _("To see the actual chain you can use openssl command")
|
|
53
53
|
$stderr.puts " $ openssl s_client -showcerts -connect #{uri.host}:#{uri.port} </dev/null"
|
|
54
54
|
$stderr.puts
|
|
55
|
-
$stderr.puts _("You can also download the certificate manually and store it as
|
|
55
|
+
$stderr.puts _("You can also download the certificate manually and store it as %s.") % cert_file
|
|
56
56
|
$stderr.puts _("If you choose any other location set the ssl_ca_path or ssl_ca_file configuration options appropriately.")
|
|
57
57
|
return HammerCLI::EX_SOFTWARE
|
|
58
58
|
rescue StandardError => e
|
|
@@ -60,7 +60,7 @@ module HammerCLI
|
|
|
60
60
|
msg = [_('Fetching the CA certificate failed:')]
|
|
61
61
|
|
|
62
62
|
if e.is_a?(OpenSSL::SSL::SSLError) && e.message.include?('unknown protocol')
|
|
63
|
-
msg << _('The service at the given URI does not accept SSL connections')
|
|
63
|
+
msg << _('The service at the given URI does not accept SSL connections.')
|
|
64
64
|
msg << scheme_error if uri.scheme == 'http'
|
|
65
65
|
else
|
|
66
66
|
msg << e.message
|
data/lib/hammer_cli/clamp.rb
CHANGED
|
@@ -2,14 +2,14 @@ require 'clamp'
|
|
|
2
2
|
|
|
3
3
|
if Clamp.respond_to?(:messages=)
|
|
4
4
|
Clamp.messages = {
|
|
5
|
-
:too_many_arguments => _("
|
|
6
|
-
:option_required => _("
|
|
7
|
-
:option_or_env_required => _("
|
|
8
|
-
:option_argument_error => _("
|
|
9
|
-
:parameter_argument_error => _("
|
|
10
|
-
:env_argument_error => _("%<env>s: %<message>s"
|
|
11
|
-
:unrecognised_option => _("Unrecognised option '%<switch>s
|
|
12
|
-
:no_such_subcommand => _("No such sub-command '%<name>s
|
|
13
|
-
:no_value_provided => _("
|
|
5
|
+
:too_many_arguments => _("Too many arguments."),
|
|
6
|
+
:option_required => _("Option '%s' is required.") % "%<option>s",
|
|
7
|
+
:option_or_env_required => _("Option '%{opt}' (or env %{env}) is required.") % {:opt => "%<option>s", :env => "%<env>s"},
|
|
8
|
+
:option_argument_error => _("Option '%{swt}': %{msg}.") % {:swt => "%<switch>s", :msg => "%<message>s"},
|
|
9
|
+
:parameter_argument_error => _("Parameter '%{pmt}': %{msg}.") % {:pmt => "%<param>s", :msg => "%<message>s"},
|
|
10
|
+
:env_argument_error => _("%{env}: %{msg}.") % {:env => "%<env>s", :msg => "%<message>s"},
|
|
11
|
+
:unrecognised_option => _("Unrecognised option '%s'.") % "%<switch>s",
|
|
12
|
+
:no_such_subcommand => _("No such sub-command '%s'.") % "%<name>s",
|
|
13
|
+
:no_value_provided => _("No value provided.")
|
|
14
14
|
}
|
|
15
15
|
end
|
data/lib/hammer_cli/context.rb
CHANGED
|
@@ -6,7 +6,8 @@ module HammerCLI
|
|
|
6
6
|
@context ||= {
|
|
7
7
|
:defaults => HammerCLI.defaults,
|
|
8
8
|
:is_tty? => HammerCLI.tty?,
|
|
9
|
-
:api_connection => HammerCLI::Connection.new(Logging.logger['Connection'])
|
|
9
|
+
:api_connection => HammerCLI::Connection.new(Logging.logger['Connection']),
|
|
10
|
+
:no_headers => HammerCLI::Settings.get(:ui, :no_headers)
|
|
10
11
|
}
|
|
11
12
|
end
|
|
12
13
|
|
data/lib/hammer_cli/defaults.rb
CHANGED
|
@@ -23,20 +23,18 @@ module HammerCLI
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def delete_default_from_conf(param)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
end
|
|
26
|
+
@defaults_settings.delete_if { |k,| defaults_match?(k, param) }
|
|
27
|
+
update_defaults_file
|
|
29
28
|
end
|
|
30
29
|
|
|
31
30
|
def add_defaults_to_conf(default_options, provider)
|
|
32
31
|
create_default_file if defaults_settings.empty?
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
defaults[key] = (value ? {:value => value} : {:provider => provider})
|
|
38
|
-
end
|
|
32
|
+
default_options.each do |key, value|
|
|
33
|
+
key = switch_to_name(key).to_sym
|
|
34
|
+
@defaults_settings.delete_if { |k,| defaults_match?(k, key) }
|
|
35
|
+
@defaults_settings[key] = (value ? {:value => value.to_s} : {:provider => provider.to_s})
|
|
39
36
|
end
|
|
37
|
+
update_defaults_file
|
|
40
38
|
end
|
|
41
39
|
|
|
42
40
|
def defaults_set?(param)
|
|
@@ -79,11 +77,11 @@ module HammerCLI
|
|
|
79
77
|
end
|
|
80
78
|
|
|
81
79
|
def update_defaults_file
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
write_to_file
|
|
86
|
-
|
|
80
|
+
conf_file_content = {
|
|
81
|
+
:defaults => @defaults_settings
|
|
82
|
+
}
|
|
83
|
+
write_to_file(conf_file_content)
|
|
84
|
+
conf_file_content
|
|
87
85
|
end
|
|
88
86
|
|
|
89
87
|
private
|
|
@@ -101,9 +101,9 @@ module HammerCLI
|
|
|
101
101
|
command_name 'add'
|
|
102
102
|
|
|
103
103
|
desc _('Add a default parameter to config')
|
|
104
|
-
option "--param-name", "OPTION_NAME", _("The name of the default option (e.g. organization_id)
|
|
104
|
+
option "--param-name", "OPTION_NAME", _("The name of the default option (e.g. organization_id)"), :required => true
|
|
105
105
|
option "--param-value", "OPTION_VALUE", _("The value for the default option")
|
|
106
|
-
option "--provider", "OPTION_PROVIDER", _("The name of the provider providing the value. For list available providers see `hammer defaults providers
|
|
106
|
+
option "--provider", "OPTION_PROVIDER", _("The name of the provider providing the value. For list available providers see `hammer defaults providers`")
|
|
107
107
|
|
|
108
108
|
def execute
|
|
109
109
|
if option_provider.nil? && option_param_value.nil? || !option_provider.nil? && !option_param_value.nil?
|
|
@@ -69,7 +69,7 @@ module HammerCLI
|
|
|
69
69
|
|
|
70
70
|
def handle_usage_exception(e)
|
|
71
71
|
print_error (_("Error: %{message}") + "\n\n" +
|
|
72
|
-
_("See: '%{path} --help'")) % {:message => e.message, :path => e.command.invocation_path}
|
|
72
|
+
_("See: '%{path} --help'.")) % {:message => e.message, :path => e.command.invocation_path}
|
|
73
73
|
log_full_error e
|
|
74
74
|
HammerCLI::EX_USAGE
|
|
75
75
|
end
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
require 'unicode'
|
|
1
2
|
module HammerCLI
|
|
2
3
|
module Help
|
|
3
4
|
class Builder < Clamp::Help::Builder
|
|
@@ -34,7 +35,7 @@ module HammerCLI
|
|
|
34
35
|
|
|
35
36
|
items.each do |item|
|
|
36
37
|
label, description = item.help
|
|
37
|
-
description.each_line do |line|
|
|
38
|
+
description.gsub(/^(.)/) { Unicode::capitalize($1) }.each_line do |line|
|
|
38
39
|
puts " %-#{label_width}s %s" % [label, line]
|
|
39
40
|
label = ''
|
|
40
41
|
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require 'rake'
|
|
2
|
+
|
|
3
|
+
module HammerCLI
|
|
4
|
+
module I18n
|
|
5
|
+
class FindTask
|
|
6
|
+
include Rake::DSL
|
|
7
|
+
|
|
8
|
+
def initialize(domain, version)
|
|
9
|
+
@domain = domain
|
|
10
|
+
@version = version
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def define
|
|
14
|
+
namespace :gettext do
|
|
15
|
+
task :setup do
|
|
16
|
+
require 'gettext/tools/task'
|
|
17
|
+
|
|
18
|
+
GetText::Tools::Task.define do |task|
|
|
19
|
+
task.package_name = @domain.domain_name
|
|
20
|
+
task.package_version = @version.to_s
|
|
21
|
+
task.domain = @domain.domain_name
|
|
22
|
+
task.mo_base_directory = @domain.locale_dir
|
|
23
|
+
task.po_base_directory = @domain.locale_dir
|
|
24
|
+
task.files = @domain.translated_files
|
|
25
|
+
task.msgmerge_options='--no-fuzzy-matching'
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
desc "Update pot file"
|
|
30
|
+
task :find => [:setup] do
|
|
31
|
+
Rake::Task["gettext:po:update"].invoke
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.define(domain, version)
|
|
37
|
+
new(domain, version).define
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
data/lib/hammer_cli/i18n.rb
CHANGED
data/lib/hammer_cli/logger.rb
CHANGED
|
@@ -55,7 +55,7 @@ module HammerCLI
|
|
|
55
55
|
begin
|
|
56
56
|
FileUtils.mkdir_p(log_dir, :mode => 0750)
|
|
57
57
|
rescue Errno::EACCES => e
|
|
58
|
-
$stderr.puts _("No permissions to create log dir %s") % log_dir
|
|
58
|
+
$stderr.puts _("No permissions to create log dir %s.") % log_dir
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
filename = "#{log_dir}/hammer.log"
|
data/lib/hammer_cli/main.rb
CHANGED
|
@@ -4,17 +4,17 @@ module HammerCLI
|
|
|
4
4
|
|
|
5
5
|
class MainCommand < AbstractCommand
|
|
6
6
|
|
|
7
|
-
option ["-v", "--verbose"], :flag, _("
|
|
8
|
-
option ["-d", "--debug"], :flag, _("
|
|
9
|
-
option ["-r", "--reload-cache"], :flag, _("
|
|
7
|
+
option ["-v", "--verbose"], :flag, _("Be verbose"), :context_target => :verbose
|
|
8
|
+
option ["-d", "--debug"], :flag, _("Show debugging output"), :context_target => :debug
|
|
9
|
+
option ["-r", "--reload-cache"], :flag, _("Force reload of Apipie cache")
|
|
10
10
|
|
|
11
|
-
option ["-c", "--config"], "CFG_FILE", _("
|
|
11
|
+
option ["-c", "--config"], "CFG_FILE", _("Path to custom config file")
|
|
12
12
|
|
|
13
|
-
option ["-u", "--username"], "USERNAME", _("
|
|
13
|
+
option ["-u", "--username"], "USERNAME", _("Username to access the remote system"),
|
|
14
14
|
:context_target => :username
|
|
15
|
-
option ["-p", "--password"], "PASSWORD", _("
|
|
15
|
+
option ["-p", "--password"], "PASSWORD", _("Password to access the remote system"),
|
|
16
16
|
:context_target => :password
|
|
17
|
-
option ["-s", "--server"], "SERVER", _("
|
|
17
|
+
option ["-s", "--server"], "SERVER", _("Remote system address"),
|
|
18
18
|
:context_target => :uri
|
|
19
19
|
option ["--verify-ssl"], "VERIFY_SSL", _("Configure SSL verification of remote system"),
|
|
20
20
|
:format => HammerCLI::Options::Normalizers::Bool.new
|
|
@@ -25,7 +25,7 @@ module HammerCLI
|
|
|
25
25
|
option ["--ssl-with-basic-auth"], :flag, _("Use standard authentication in addition to client certificate authentication")
|
|
26
26
|
option ["--fetch-ca-cert"], "SERVER", _("Fetch CA certificate from server and exit")
|
|
27
27
|
|
|
28
|
-
option "--version", :flag, _("
|
|
28
|
+
option "--version", :flag, _("Show version") do
|
|
29
29
|
puts "hammer (%s)" % HammerCLI.version
|
|
30
30
|
HammerCLI::Modules.names.each do |m|
|
|
31
31
|
module_version = HammerCLI::Modules.find_by_name(m).version rescue _("unknown version")
|
|
@@ -39,7 +39,7 @@ module HammerCLI
|
|
|
39
39
|
option ["--interactive"], "INTERACTIVE", _("Explicitly turn interactive mode on/off"),
|
|
40
40
|
:format => HammerCLI::Options::Normalizers::Bool.new,
|
|
41
41
|
:context_target => :interactive
|
|
42
|
-
|
|
42
|
+
option ["--no-headers"], :flag, _("Hide headers from output")
|
|
43
43
|
option ["--csv"], :flag, _("Output as CSV (same as --output=csv)")
|
|
44
44
|
option ["--output"], "ADAPTER", _("Set output format. One of [%s]") %
|
|
45
45
|
HammerCLI::Output::Output.adapters.keys.join(', '),
|
|
@@ -61,8 +61,9 @@ module HammerCLI
|
|
|
61
61
|
context[:adapter] = :csv
|
|
62
62
|
end
|
|
63
63
|
|
|
64
|
+
def option_no_headers=(no_headers)
|
|
65
|
+
context[:no_headers] = :no_headers
|
|
66
|
+
end
|
|
64
67
|
end
|
|
65
68
|
|
|
66
69
|
end
|
|
67
|
-
|
|
68
|
-
|
data/lib/hammer_cli/modules.rb
CHANGED
|
@@ -7,10 +7,7 @@ module HammerCLI
|
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
def self.enabled_modules
|
|
10
|
-
|
|
11
|
-
modules = HammerCLI::Settings.get(:modules) || []
|
|
12
|
-
logger.warn _("Legacy configuration of modules detected. Check section about configuration in user manual") unless modules.empty?
|
|
13
|
-
|
|
10
|
+
modules = []
|
|
14
11
|
HammerCLI::Settings.dump.inject(modules) do |names, (mod_name, mod_config)|
|
|
15
12
|
if is_module_config?(mod_config)
|
|
16
13
|
mod = ["hammer_cli_#{mod_name}"]
|
|
@@ -56,15 +53,15 @@ module HammerCLI
|
|
|
56
53
|
begin
|
|
57
54
|
require_module(name)
|
|
58
55
|
rescue Exception => e
|
|
59
|
-
logger.error "Error while loading module #{name}"
|
|
60
|
-
puts _("Warning: An error occured while loading module %s") % name
|
|
56
|
+
logger.error "Error while loading module #{name}."
|
|
57
|
+
puts _("Warning: An error occured while loading module %s.") % name
|
|
61
58
|
# with ModuleLoadingError we assume the error is already logged by the issuer
|
|
62
59
|
logger.error e unless e.is_a?(HammerCLI::ModuleLoadingError)
|
|
63
60
|
raise e
|
|
64
61
|
end
|
|
65
62
|
|
|
66
63
|
version = find_by_name(name).version
|
|
67
|
-
logger.info "Extension module #{name} (#{version}) loaded"
|
|
64
|
+
logger.info "Extension module #{name} (#{version}) loaded."
|
|
68
65
|
true
|
|
69
66
|
end
|
|
70
67
|
|
|
@@ -84,7 +81,7 @@ module HammerCLI
|
|
|
84
81
|
end
|
|
85
82
|
loaded_for_deps = loaded_modules & disabled_modules
|
|
86
83
|
unless loaded_for_deps.empty?
|
|
87
|
-
message = _("Error: Some of the required modules are disabled in configuration: %s
|
|
84
|
+
message = _("Error: Some of the required modules are disabled in configuration: %s.") % loaded_for_deps.join(', ')
|
|
88
85
|
raise HammerCLI::ModuleDisabledButRequired.new(message)
|
|
89
86
|
end
|
|
90
87
|
end
|