Commits

Shlomi Fish committed 385a8ff

Add the --man and --help flags.

  • Participants
  • Parent commits 5d109a1

Comments (0)

Files changed (1)

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

 use strict;
 use warnings;
 
+
 use Getopt::Long qw(GetOptionsFromArray);
+use Pod::Usage;
 
 use Module::Format::ModuleList;
 
 
     my $op = shift(@$argv);
 
+    if (!defined($op))
+    {
+        die "You did not specify any arguments - see --help";
+    }
+
+    if (($op eq "-h") || ($op eq "--help"))
+    {
+        pod2usage(1);
+    }
+    elsif ($op eq "--man")
+    {
+        pod2usage(-verbose => 2);
+    }
+
     if (! exists( $ops_to_formats{$op} ))
     {
         die "Unknown op '$op'.";
     my $delim = ' ';
     my $suffix = "\n";
 
+    my $help = 0;
+    my $man = 0;
     if (! (my $ret = GetOptionsFromArray(
         $argv,
         '0!' => sub { $delim = "\0"; $suffix = q{}; },
         'n!' => sub { $delim = "\n"; $suffix = "\n"; },
+        'help|h' => \$help,
+        man => \$man,
     )))
     {
         die "GetOptions failed!";
     }
 
+    if ($help)
+    {
+        pod2usage(1);
+    }
+
+    if ($man)
+    {
+        pod2usage(-verbose => 2);
+    }
+
     my @strings = @$argv;
 
     my $module_list_obj = Module::Format::ModuleList->sane_from_guesses(