77import re
88import sys
99
10- import language_tool
10+ import language_tool . console_mode
1111
1212DEFAULT_ENCODING = "utf-8"
1313
@@ -19,11 +19,11 @@ def parse_args():
1919 "language_tool" )
2020 )
2121 parser .add_argument ("file" ,
22- help = 'plain text file or "-" for stdin' )
22+ help = 'plain text file or “-” for stdin' )
2323 parser .add_argument ("-c" , "--encoding" ,
2424 help = "input encoding" )
2525 parser .add_argument ("-l" , "--language" , metavar = "CODE" ,
26- help = 'language code of the input or " auto" ' )
26+ help = 'language code of the input or “ auto” ' )
2727 parser .add_argument ("-m" , "--mother-tongue" , metavar = "CODE" ,
2828 help = "language code of your first language" )
2929 parser .add_argument ("-d" , "--disable" , metavar = "RULES" , type = get_rules ,
@@ -32,8 +32,10 @@ def parse_args():
3232 help = "list of rule IDs to be enabled" )
3333 parser .add_argument ("--api" , action = "store_true" ,
3434 help = "print results as XML" )
35- parser .add_argument ("--version" , action = "store_true" ,
36- help = "print LanguageTool version number" )
35+ parser .add_argument ("--version" , action = "version" ,
36+ version = "LanguageTool {}"
37+ .format (language_tool .get_version ()),
38+ help = "show LanguageTool version number" )
3739 parser .add_argument ("-a" , "--apply" , action = "store_true" ,
3840 help = "automatically apply suggestions if available" )
3941 parser .add_argument ("-s" , "--spell-check" , action = "store_true" ,
@@ -54,10 +56,6 @@ def get_text(file, encoding):
5456def main ():
5557 args = parse_args ()
5658
57- if args .version :
58- print ("LanguageTool {}" .format (language_tool .get_version ()))
59- return
60-
6159 if args .file == "-" :
6260 file = sys .stdin .fileno ()
6361 encoding = args .encoding or (
0 commit comments