Skip to content

Commit 2311423

Browse files
committed
Add indent parameter to format subcommand
1 parent d842ba0 commit 2311423

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/cfengine_cli/format.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def split_rval_list(node, indent, args):
109109
first = text(node.children[0])
110110
last = " " * indent + text(node.children[-1])
111111
middle = node.children[1:-1]
112-
elements = maybe_split_generic_list(middle, indent + 2, args)
112+
elements = maybe_split_generic_list(middle, indent + args.indent, args)
113113
return [first, *elements, last]
114114

115115

@@ -120,7 +120,7 @@ def split_rval_call(node, indent, args):
120120
first = text(node.children[0]) + "("
121121
last = " " * indent + text(node.children[-1])
122122
middle = node.children[2:-1]
123-
elements = maybe_split_generic_list(middle, indent + 2, args)
123+
elements = maybe_split_generic_list(middle, indent + args.indent, args)
124124
return [first, *elements, last]
125125

126126

@@ -188,7 +188,7 @@ def autoformat(node, fmt, args, macro_indent, indent=0):
188188
"promise",
189189
"attribute",
190190
]:
191-
indent += 2
191+
indent += args.indent
192192
if node.type == "attribute":
193193
lines = stringify(node, indent, args)
194194
fmt.print_lines(lines, indent=0)

src/cfengine_cli/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def _get_arg_parser():
4646
fmt.add_argument(
4747
"--max-line-length", default=80, type=int, help="Maximum line length"
4848
)
49+
fmt.add_argument("--indent", default=2, type=int, help="Indentation increase")
4950
subp.add_parser(
5051
"lint",
5152
help="Look for syntax errors and other simple mistakes",

0 commit comments

Comments
 (0)