2525Examples:
2626 echo 'pass' | gdformat - # reads from STDIN
2727"""
28+
2829import sys
2930import os
3031import logging
@@ -69,14 +70,6 @@ def main():
6970 if arguments ["--diff" ]:
7071 arguments ["--check" ] = True
7172
72- line_length = int (arguments ["--line-length" ])
73- spaces_for_indent = (
74- int (arguments ["--use-spaces" ])
75- if arguments ["--use-spaces" ] is not None
76- else None
77- )
78- safety_checks = not arguments ["--fast" ]
79-
8073 config_file_path = _find_config_file ()
8174 config = _load_config_file_or_default (config_file_path )
8275 _log_config_entries (config )
@@ -86,6 +79,24 @@ def main():
8679 arguments ["<path>" ], excluded_directories = set (config ["excluded_directories" ])
8780 )
8881
82+ line_length = (
83+ int (arguments ["--line-length" ])
84+ if arguments ["--line-length" ]
85+ else config .get ("line_length" , DEFAULT_CONFIG ["line_length" ])
86+ )
87+
88+ spaces_for_indent = (
89+ int (arguments ["--use-spaces" ])
90+ if arguments ["--use-spaces" ]
91+ else config .get ("use_spaces" , DEFAULT_CONFIG ["use_spaces" ])
92+ )
93+
94+ safety_checks = (
95+ not arguments ["--fast" ]
96+ if arguments .get ("--fast" )
97+ else config .get ("safety_checks" , DEFAULT_CONFIG ["safety_checks" ])
98+ )
99+
89100 if files == ["-" ]:
90101 _format_stdin (line_length , spaces_for_indent , safety_checks )
91102 elif arguments ["--check" ]:
0 commit comments