25
25
Examples:
26
26
echo 'pass' | gdformat - # reads from STDIN
27
27
"""
28
+
28
29
import sys
29
30
import os
30
31
import logging
@@ -69,14 +70,6 @@ def main():
69
70
if arguments ["--diff" ]:
70
71
arguments ["--check" ] = True
71
72
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
-
80
73
config_file_path = _find_config_file ()
81
74
config = _load_config_file_or_default (config_file_path )
82
75
_log_config_entries (config )
@@ -86,6 +79,24 @@ def main():
86
79
arguments ["<path>" ], excluded_directories = set (config ["excluded_directories" ])
87
80
)
88
81
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
+
89
100
if files == ["-" ]:
90
101
_format_stdin (line_length , spaces_for_indent , safety_checks )
91
102
elif arguments ["--check" ]:
0 commit comments