]> Sergey Matveev's repositories - swg.git/commitdiff
files subcommand
authorSergey Matveev <stargrave@stargrave.org>
Mon, 2 Jun 2025 10:18:23 +0000 (13:18 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Mon, 2 Jun 2025 10:18:23 +0000 (13:18 +0300)
swg

diff --git a/swg b/swg
index fdf6956c6f95495c1626ed5bc71b574bde820e08..6a940f7f6511667e38c0d78b916ac9175cd0ddb3 100755 (executable)
--- a/swg
+++ b/swg
@@ -17,12 +17,18 @@ my $CR = "\r";
 sub usage {
     print {*STDERR} <<"END_USAGE"
 Usage:
-    $0 links PAGE
-    $0 backs PAGE
-    $0 cats [PREFIX]
-    $0 htmls DIR
-    $0 dot | dot -Tpng >relations.png
+    $0 links PAGE    -- show links on the PAGE
+    $0 backs PAGE    -- show backlinks to the PAGE
+    $0 cats [PREFIX] -- show categories
+    $0 htmls DIR     -- render HTMLs in DIR
     $0 info >out.info
+    $0 dot | dot -Tpng >relations.png
+
+For debugging:
+    $0 files -- list files that will be processed
+    $0 dump  -- dump links/backlinks information
+    $0 html PAGE >PAGE.html
+    $0 gen-index CAT >CAT.html
 
 By default SWG_DO_BACKS=1 is set.
 Do not forget about .swgignore with regular expressions.
@@ -71,6 +77,10 @@ use File::Basename;
         foreach (@ignores) {
             return if $pth =~ /$_/;
         }
+        if ($ARGV[0] eq q{files}) {
+            print "$pth\n";
+            return;
+        }
         $cat = dirname $pth;
         $cat = ($cat eq q{.}) ? q{/} : "$cat/";
         if (-d $fn) {
@@ -442,7 +452,9 @@ sub genInfoIndex {
     return;
 }
 
-if ($ARGV[0] eq q{dump}) {
+if ($ARGV[0] eq q{files}) {
+    # do nothing
+} elsif ($ARGV[0] eq q{dump}) {
     require Data::Dumper;
     print Data::Dumper->Dump([
         \%Links,
@@ -474,7 +486,7 @@ if ($ARGV[0] eq q{dump}) {
 } elsif ($ARGV[0] eq q{gen-index}) {
     my $p = decode q{UTF-8}, $ARGV[1];
     genIndex \*STDOUT, $p;
-} elsif ($ARGV[0] eq q{gen-html}) {
+} elsif ($ARGV[0] eq q{html}) {
     my $p = decode q{UTF-8}, $ARGV[1];
     if ($p =~ /\/$/) {
         genHTML \*STDOUT, $p, genIndex2Buf $p;