Skip to content

Commit aca4d24

Browse files
chris-laplantepelwell
authored andcommitted
ovmerge: add -S option to use spaces for indentation
Signed-off-by: Chris Laplante <[email protected]>
1 parent 1e2169a commit aca4d24

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

ovmerge/ovmerge

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ my $retcode = 0;
9898
my $query = 0;
9999
my $trace_prop;
100100
my $trace_label;
101+
my $indent_str = "\t";
101102

102103
my @redo_comments;
103104
my @cmdline;
@@ -180,6 +181,22 @@ while ($ARGV[0] =~ /^-/)
180181
{
181182
$query = 1;
182183
}
184+
elsif ($arg eq '-S')
185+
{
186+
my $indent_spaces = shift @ARGV;
187+
if (!defined $indent_spaces)
188+
{
189+
print STDERR ("* Spaces count parameter missing\n");
190+
usage();
191+
}
192+
elsif ($indent_spaces !~ /^\d+$/)
193+
{
194+
print STDERR ("* Invalid spaces count parameter. Expected an integer.\n");
195+
usage();
196+
}
197+
$indent_str = ' ' x $indent_spaces;
198+
push @cmdline, $arg, $indent_spaces;
199+
}
183200
else
184201
{
185202
print STDERR ("* Unknown option '$arg'\n");
@@ -1161,17 +1178,15 @@ sub resolve_alias
11611178
sub dump_node
11621179
{
11631180
my ($node, $depth) = @_;
1164-
my $indent = "\t" x $depth;
1181+
my $indent = $indent_str x $depth;
11651182

11661183
print($indent, join(': ', get_labels($node), $node->[0]), " {\n");
11671184

1168-
$indent = "\t" x $depth;
1169-
11701185
# Properties
11711186
foreach my $prop (get_props($node))
11721187
{
11731188
my @terms;
1174-
print($indent, "\t", $prop->[0]);
1189+
print($indent, $indent_str, $prop->[0]);
11751190
for (my $i = 1; $i < @$prop; $i++)
11761191
{
11771192
my $chunk = $prop->[$i];
@@ -2068,6 +2083,7 @@ sub usage
20682083
print STDERR (" -p Emulate Pi firmware manipulation\n");
20692084
print STDERR (" -r Redo command comment in named files (c.f. '-c')\n");
20702085
print STDERR (" -s Sort nodes and properties (for easy comparison)\n");
2086+
print STDERR (" -S <n> Instead of tabs, use 'n' spaces for indentation\n");
20712087
print STDERR (" -t Trace\n");
20722088
print STDERR (" -w Show warnings\n");
20732089

0 commit comments

Comments
 (0)