Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion show/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1712,9 +1712,12 @@ def version(verbose):

@cli.command()
@click.option('--verbose', is_flag=True, help="Enable verbose output")
def environment(verbose):
@click.option('--json', '-j', is_flag=True, help="Output in json format")
def environment(verbose, json):
"""Show environmentals (voltages, fans, temps)"""
cmd = ['sudo', 'sensors']
if json:
cmd.append('-j')
run_command(cmd, display_cmd=verbose)


Expand Down
7 changes: 7 additions & 0 deletions tests/show_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,13 @@ def test_show_environment(self, mock_run_command):
assert result.exit_code == 0
mock_run_command.assert_called_with(['sudo', 'sensors'], display_cmd=True)

@patch('show.main.run_command')
def test_show_environment_json(self, mock_run_command):
runner = CliRunner()
result = runner.invoke(show.cli.commands['environment'], ['--json'])
assert result.exit_code == 0
mock_run_command.assert_called_with(['sudo', 'sensors', '-j'], display_cmd=False)

@patch('show.main.run_command')
def test_show_users(self, mock_run_command):
runner = CliRunner()
Expand Down
Loading