Commits

Shlomi Fish  committed be92784

Add the --gen-v1-template flag.

  • Participants
  • Parent commits b2c70d6

Comments (0)

Files changed (4)

File abc-path/Games-ABC_Path-Solver/Changes

 Revision history for Games-ABC_Path-Solver
 
+0.4.0   2014-03-06
+        - Add the --gen-v1-template flag to generate a skeleton file.
+
 0.3.3   2014-01-30
         - Explicit minimal perl version - 5.8 (CPANTS Kwalitee)
         - Add LICENSE file.

File abc-path/Games-ABC_Path-Solver/lib/Games/ABC_Path/Solver/App.pm

 
     my $man = 0;
     my $help = 0;
-    GetOptions('help|h' => \$help, man => \$man)
+    my $gen_template = 0;
+    GetOptions(
+        'help|h' => \$help,
+        man => \$man,
+        'gen-v1-template' => \$gen_template,
+    )
         or pod2usage(2);
 
     if ($help)
     {
         pod2usage(1);
     }
-
-    if ($man)
+    elsif ($man)
     {
         pod2usage(-verbose => 2);
     }
+    elsif ($gen_template)
+    {
+        print <<'EOF';
+ABC Path Solver Layout Version 1:
+???????
+?     ?
+?     ?
+?     ?
+?   A ?
+?     ?
+???????
+EOF
+    }
+    else
+    {
 
-    my $board_fn = shift(@ARGV);
+        my $board_fn = shift(@ARGV);
 
-    if (!defined ($board_fn))
-    {
-        die "Filename not specified - usage: abc-path-solver.pl [filename]!";
+        if (!defined ($board_fn))
+        {
+            die "Filename not specified - usage: abc-path-solver.pl [filename]!";
+        }
+
+        my $solver = Games::ABC_Path::Solver::Board->input_from_file($board_fn);
+        # Now let's do a neighbourhood inferring of the board.
+
+        $solver->solve;
+
+        foreach my $move (@{$solver->get_moves})
+        {
+            print +(' => ' x $move->get_depth()), $move->get_text(), "\n";
+        }
+
+        print @{$solver->get_successes_text_tables};
     }
 
-    my $solver = Games::ABC_Path::Solver::Board->input_from_file($board_fn);
-    # Now let's do a neighbourhood inferring of the board.
-
-    $solver->solve;
-
-    foreach my $move (@{$solver->get_moves})
-    {
-        print +(' => ' x $move->get_depth()), $move->get_text(), "\n";
-    }
-
-    print @{$solver->get_successes_text_tables};
-
     exit(0);
 }
 

File abc-path/Games-ABC_Path-Solver/scripts/abc-path-solve

 
 B<abc-path-solve> /path/to/board
 
+B<abc-path-solve> --gen-v1-template
+
 =head1 DESCRIPTION
 
 This is a solver for ABC Path ( L<http://www.brainbashers.com/abcpath.asp> ).
 
 Sample boards can be found in the distribution under C<t/layouts/> .
 
-Here is the description of their formats. The first line should be the
+Here is the description of their format. The first line should be the
 magic string C<ABC Path Solver Layout Version 1:> , and the next line should
 be a row of 7 letters, the first being a hint for the top-left-to-bottom-right
-perpendicular, the last being a hint for the top-right-to-bottom-left 
-perpendicular and the rest of the letters being vertical hints. 
+perpendicular, the last being a hint for the top-right-to-bottom-left
+perpendicular and the rest of the letters being vertical hints.
 
 After that, there are 5 rows of horizontal hints being a letter, 5 spaces
 and another letter. On one of the squares one can put a letter instead of a
     R     S
     TVMGCDH
 
+One can also generate a skeleton for such a layout using the
+B<--gen-v1-template> flag.
+
 =cut
 
 =head1 SEE ALSO

File abc-path/Games-ABC_Path-Solver/t/solver-output-system-test.t

 use strict;
 use warnings;
 
-use Test::More tests => 4;
+use Test::More tests => 6;
 use Test::Differences qw( eq_or_diff );
 
 sub _slurp
         "Output is OK.",
     );
 }
+
+{
+    my $got_results =
+        `$^X -Mblib scripts/abc-path-solve --gen-v1-template`
+        ;
+
+    # TEST
+    ok ((!$?), "Process ended successfully.");
+
+    my $v1_template__exp_results = <<'EOF';
+ABC Path Solver Layout Version 1:
+???????
+?     ?
+?     ?
+?     ?
+?   A ?
+?     ?
+???????
+EOF
+
+    # TEST
+    eq_or_diff(
+        $got_results,
+        $v1_template__exp_results,
+        "Output of --gen-v1-template is OK.",
+    );
+}
+
 =head1 COPYRIGHT AND LICENSE
 
 Copyright (c) 2010 Shlomi Fish