Commits

Shlomi Fish committed 7f7a20b

Add more formats.

Comments (0)

Files changed (2)

Module-Format/Module-Format/lib/Module/Format/PerlMF_App.pm

 
 =cut
 
+my %ops_to_formats =
+(
+    'as_rpm_colon' => 'rpm_colon',
+    'rpm_colon' => 'rpm_colon',
+    'as_rpm_c' => 'rpm_colon',
+    'rpm_c' => 'rpm_colon',
+    'as_rpm_dash' => 'rpm_dash',
+    'rpm_dash' => 'rpm_dash',
+    'as_rpm_d' => 'rpm_dash',
+    'rpm_d' => 'rpm_dash',
+    'dash' => 'dash',
+    'as_dash' => 'dash',
+    'colon' => 'colon',
+    'as_colon' => 'colon',
+    'deb' => 'debian',
+    'as_deb' => 'debian',
+    'debian' => 'debian',
+    'as_debian' => 'debian',
+);
+
 sub run
 {
     my ($self) = @_;
 
     my $op = shift(@$argv);
 
-    if ($op ne "as_rpm_colon")
+    if (! exists( $ops_to_formats{$op} ))
     {
         die "Unknown op '$op'.";
     }
 
+    my $format = $ops_to_formats{$op};
+
     if (! (my $ret = GetOptionsFromArray(
         $argv
     )))
         }
     );
 
-    print join(' ', @{$module_list_obj->format_as('rpm_colon')}), "\n";
+    print join(' ', @{$module_list_obj->format_as($format)}), "\n";
 
     return;
 }

Module-Format/Module-Format/t/perlmf-app.t

     plan skip_all => "Test::Trap not found.";
 }
 
-plan tests => 2;
+plan tests => 3;
 
 # TEST
 ok(1, "Test is OK.");
         'as_rpm_colon works as expected.',
     );
 }
+
+{
+    trap(sub {
+        Module::Format::PerlMF_App->new(
+            {
+                argv => [qw/as_colon Data::Dump XML-Grammar-Fortune/],
+            },
+        )->run();
+    });
+
+    # TEST
+    is (
+        $trap->stdout(), 
+        qq{Data::Dump XML::Grammar::Fortune\n},
+        'as_colon works as expected.',
+    );
+}