Skip to content

Commit 8d9869a

Browse files
authored
No ‘null’ output if command doesn’t return (#1913)
- This prevents commands from printing ‘null’ in JSON output - But still keeps ‘[]’, ‘{}’, and ‘false’ as valid JSON results Closes #1908
1 parent 84ca14e commit 8d9869a

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

src/azure-cli-core/azure/cli/core/test_utils/vcr_test_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def __init__(self):
164164
pass
165165

166166
def compare(self, data): # pylint: disable=no-self-use
167-
none_strings = ['[]', '{}', 'null', 'false']
167+
none_strings = ['[]', '{}', 'false']
168168
try:
169169
assert not data or data in none_strings
170170
except AssertionError:

src/azure-cli/azure/cli/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def main(args, file=sys.stdout): # pylint: disable=redefined-builtin
3838

3939
# Commands can return a dictionary/list of results
4040
# If they do, we print the results.
41-
if cmd_result:
41+
if cmd_result and cmd_result.result is not None:
4242
from azure.cli.core._output import OutputProducer
4343
formatter = OutputProducer.get_formatter(APPLICATION.configuration.output_format)
4444
OutputProducer(formatter=formatter, file=file).out(cmd_result)

0 commit comments

Comments
 (0)