From 899d390b70beebae59c19498be853274ccee4b32 Mon Sep 17 00:00:00 2001 From: Nathan Gill Date: Mon, 9 Feb 2026 11:51:15 +0000 Subject: [PATCH] add option to display variables defined in a template --- lic.pl | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lic.pl b/lic.pl index b2cde88..b4fc094 100755 --- a/lic.pl +++ b/lic.pl @@ -34,7 +34,8 @@ sub version { } my $license; -my $head = 0; +my $opt_head = 0; +my $opt_vars = 0; my @substs = (); my $file; @@ -48,7 +49,10 @@ for my $arg (@ARGV) { exit; } elsif ($arg eq "-H" || $arg eq "--head") { - $head = 1; + $opt_head = 1; + } + elsif ($arg eq "-v" || $arg eq "--vars") { + $opt_vars = 1; } elsif (!defined $license) { $license = $arg; @@ -64,7 +68,7 @@ unless (defined $license) { } # license headers use .head extension -if ($head == 1) { +if ($opt_head == 1) { $license .= ".head"; } @@ -103,6 +107,13 @@ while (<$input>) { chomp; my $line = $_; + if ($opt_vars == 1) { + for my $key ($line =~ /\{\{\s*([^}]+)\s*\}\}/g) { + print $key, "\n"; + } + next; + } + foreach my $subst (@substs) { my ($key, $val) = @$subst; $line =~ s/\{\{\s*\Q$key\E\s*\}\}/$val/g; -- 2.51.2