1
1
# Command line interface for the coloredlogs package.
2
2
#
3
3
# Author: Peter Odding <[email protected] >
4
- # Last Change: October 14, 2015
4
+ # Last Change: May 18, 2017
5
5
# URL: https://coloredlogs.readthedocs.io
6
6
7
7
"""
44
44
import webbrowser
45
45
46
46
# External dependencies.
47
- from humanfriendly .terminal import connected_to_terminal , usage
47
+ from humanfriendly .terminal import connected_to_terminal , output , usage , warning
48
48
49
49
# Modules included in our package.
50
50
from coloredlogs .converter import capture , convert
55
55
56
56
57
57
def main ():
58
- """Command line interface for the `coloredlogs` program."""
58
+ """Command line interface for the `` coloredlogs` ` program."""
59
59
actions = []
60
60
try :
61
61
# Parse the command line arguments.
@@ -78,7 +78,7 @@ def main():
78
78
usage (__doc__ )
79
79
return
80
80
except Exception as e :
81
- sys . stderr . write ("Error: %s\n " % e )
81
+ warning ("Error: %s" , e )
82
82
sys .exit (1 )
83
83
for function in actions :
84
84
function ()
@@ -92,11 +92,11 @@ def convert_command_output(*command):
92
92
(emulating an interactive terminal), intercepts the output of the command
93
93
and converts ANSI escape sequences in the output to HTML.
94
94
"""
95
- html_output = convert (capture (command ))
95
+ html = convert (capture (command ))
96
96
if connected_to_terminal ():
97
97
fd , temporary_file = tempfile .mkstemp (suffix = '.html' )
98
98
with open (temporary_file , 'w' ) as handle :
99
- handle .write (html_output )
99
+ handle .write (html )
100
100
webbrowser .open (temporary_file )
101
101
else :
102
- print ( html_output )
102
+ output ( html )
0 commit comments