#!/usr/bin/perl

use strict;
use Lingua::EN::Inflect qw(classical inflect PL_N PL_V);

use autouse qw(Pod::Usage pod2usage);
use Getopt::Long 2.24 qw(GetOptions :config gnu_getopt);
my $mode = "interp";
GetOptions
	"c|classical!"	=> sub { classical $_[1] },
	"n|noun"	=> sub { $mode = "noun" },
	"v|verb"	=> sub { $mode = "verb" },
	"h|help"	=> sub { pod2usage("00") }
		or pod2usage(2);
pod2usage("$0: not enough arguments")	if @ARGV < 2 - ($mode eq "interp");
pod2usage("$0: too many arguments")	if @ARGV > 2 - ($mode eq "interp");

if ($mode eq "noun") {
	print PL_N(@ARGV[1,0]);
} elsif ($mode eq "verb") {
	print PL_V(@ARGV[1,0]);
} else {
	print inflect($ARGV[0]);
}
print "\n";

__END__

=head1	NAME

inflect - perform plural inflections

=head1	SYNOPSIS

B<inflect> [B<-c>|B<--classical>] I<STR>

B<inflect> [B<-c>|B<--classical>] B<-n>|B<--noun> I<NUM> I<NOUN>

B<inflect> [B<-c>|B<--classical>] B<-v>|B<--verb> I<NUM> I<VERB>

B<inflect> B<-h>|B<--help>

  inflect --noun 2 item		# items
  inflect --verb 2 has		# have
  inflect "The plural of $word is PL($word)"
  inflect "$n PL_N(package,$n) PL_V(has,$n) $m PL_N(bug,$m)"

=head1	DESCRIPTION

TODO: complete docs.

Interpolate "PL()", "PL_N()", "PL_V()", "PL_ADJ()", "A()", "AN()",
"NUM()" and "ORD()" within strings.

=head1	OPTIONS

=over

=item	B<-c>, B<--classical>

Require "classical" plurals.

=item	B<-h>, B<--help>

Display this help and exit.

=back

=head1	AUTHOR

Written by Alexey Tourbin <at@altlinux.org>.

=head1	COPYING

Copyright (c) 2005 Alexey Tourbin, ALT Linux Team.

This is free software; you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later version.

=head1	SEE ALSO

Lingua::EN::Inflect

=cut
