New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core/configure] add '--output none'. #8198

Merged
merged 3 commits into from Jan 9, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+51 −5
Diff settings

Always

Just for now

@@ -5,7 +5,7 @@ Release History

2.0.55
++++++
* Minor fixes
* `--output`: Introduce 'none' as an output format option.

2.0.54
++++++
@@ -9,13 +9,21 @@
class AzOutputProducer(knack.output.OutputProducer):
def __init__(self, cli_ctx=None):
super(AzOutputProducer, self).__init__(cli_ctx)
super(AzOutputProducer, self)._FORMAT_DICT['yaml'] = self.format_yaml
additional_formats = {
'yaml': self.format_yaml,
'none': self.format_none
}
super(AzOutputProducer, self)._FORMAT_DICT.update(additional_formats)

@staticmethod
def format_yaml(obj):
import yaml
return yaml.safe_dump(obj.result, default_flow_style=False)

@staticmethod
def format_none(_):
return ""

def check_valid_format_type(self, format_type):
return format_type in self._FORMAT_DICT

@@ -12,8 +12,9 @@ def test_create_AzOutputProducer(self):
from azure.cli.core.mock import DummyCli

output_producer = AzOutputProducer(DummyCli())
self.assertEqual(5, len(output_producer._FORMAT_DICT)) # five types: json, jsonc, table, tsv, yaml
self.assertEqual(6, len(output_producer._FORMAT_DICT)) # six types: json, jsonc, table, tsv, yaml, none
self.assertIn('yaml', output_producer._FORMAT_DICT)
self.assertIn('none', output_producer._FORMAT_DICT)


if __name__ == '__main__':
@@ -2,6 +2,9 @@
Release History
===============
2.0.20
++++++
* Add 'none' as a configurable output format.

2.0.19
++++++
@@ -9,7 +9,8 @@
'desc': 'Colored JSON formatted output that most closely matches API responses.'},
{'name': 'table', 'desc': 'Human-readable output format.'},
{'name': 'tsv', 'desc': 'Tab- and Newline-delimited. Great for GREP, AWK, etc.'},
{'name': 'yaml', 'desc': 'YAML formatted output. An alternative to JSON. Great for configuration files.'}
{'name': 'yaml', 'desc': 'YAML formatted output. An alternative to JSON. Great for configuration files.'},
{'name': 'none', 'desc': 'No output, except for errors and warnings.'}
]

LOGIN_METHOD_LIST = [
@@ -0,0 +1,4 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
@@ -0,0 +1,4 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
@@ -0,0 +1,25 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

import unittest


class TestConfigure(unittest.TestCase):
def test_configure_output_options(self):
from azure.cli.core._output import AzOutputProducer
from azure.cli.core.mock import DummyCli
from azure.cli.command_modules.configure._consts import OUTPUT_LIST

output_producer = AzOutputProducer(DummyCli())
cli_output_options = set(output_producer._FORMAT_DICT.keys())
configure_output_options = set(item["name"] for item in OUTPUT_LIST)

self.assertEqual(cli_output_options, configure_output_options,
"\n{}'s output options: {}\ndon't match az configure's output options ({})."
.format(AzOutputProducer.__name__, cli_output_options, configure_output_options))


if __name__ == '__main__':
unittest.main()
@@ -15,7 +15,7 @@
cmdclass = {}


VERSION = "2.0.19"
VERSION = "2.0.20"
CLASSIFIERS = [
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
ProTip! Use n and p to navigate between commits in a pull request.