]> granicus.if.org Git - fortune-mod/commitdiff
Extract a method or a function.
authorShlomi Fish <shlomif@shlomifish.org>
Sat, 15 Aug 2020 15:13:30 +0000 (18:13 +0300)
committerShlomi Fish <shlomif@shlomifish.org>
Wed, 16 Sep 2020 11:00:36 +0000 (14:00 +0300)
This is Refactoring / code cleanup.

See:

* https://refactoring.com/catalog/extractMethod.html

* https://en.wikipedia.org/wiki/Code_refactoring

* https://www.refactoring.com/

* https://www.joelonsoftware.com/2002/01/23/rub-a-dub-dub/

Some small optimisations may have slipped in as well.

fortune-mod/fortune/gen-strfile-manpage.pl

index 432e8f8c179e437907ee6a399b275b859b49df9d..e1379cd9f184275c3f33e960969a818575618e7e 100644 (file)
@@ -7,6 +7,20 @@ use autodie;
 use Getopt::Long qw/ GetOptions /;
 use Path::Tiny qw/ path tempdir tempfile cwd /;
 
+sub do_system
+{
+    my ( $self, $args ) = @_;
+
+    my $cmd = $args->{cmd};
+    print "Running [@$cmd]\n";
+    if ( system(@$cmd) )
+    {
+        die "Running [@$cmd] failed!";
+    }
+
+    return;
+}
+
 my $output_fn;
 my $cookiedir;
 my $ocookiedir;
@@ -21,9 +35,14 @@ GetOptions(
 ) or die "Wrong options - $!";
 
 die "missing --src-dir" if ( not $CMAKE_CURRENT_SOURCE_DIR );
-system( qw# docmake manpages #,
-    "${CMAKE_CURRENT_SOURCE_DIR}/util/strfile.docbook5.xml" )
-    and die "system failed";
+__PACKAGE__->do_system(
+    {
+        cmd => [
+            "docmake", "manpages",
+            "${CMAKE_CURRENT_SOURCE_DIR}/util/strfile.docbook5.xml",
+        ],
+    },
+);
 
 path("${CMAKE_CURRENT_SOURCE_DIR}/util/strfile.man")
     ->spew_utf8(