BBCode-Parser

 view release on metacpan or  search on metacpan

bbtest  view on Meta::CPAN

	print <<"EOF";
Usage: bbtest [options] <code> [ [options] <code> ... ]
Options:
  -?    --help          Display this usage information
  -V    --version       Display version information

  -v    --verbose       Turn on noisy error reporting

  -o    --output fmt    Output <code> in format <fmt>
  -B    --bbcode        Print <code> as BBCode
  -H    --html          Print <code> as HTML
  -T    --text          Print <code> as plain text
  -L    --link-list     Print <code> as a list of hyperlinks

  -O    --option k=v    Set option <k> to value <v>
  -P    --permit tag    Mark BBCode <tag> as permitted
  -F    --forbid tag    Mark BBCode <tag> as forbidden

  -f    --file fn       Use the contents of <fn> instead of <code>
  -e    --encoding enc  Use <enc> as the encoding for all input and output
  -8    --utf-8         Equivalent to "--encoding UTF-8"

EOF
}

sub doVersion {
	print "BBTest, version $VERSION\n";
	print "Using BBCode::Parser version $BBCode::Parser::VERSION\n";
	print "Copyright (C)2005-2006 by Donald King <dlking\@cpan.org>\n";
	print "See LICENSE for copyright information\n";
}

GetOptions(
	'help|usage|h|?'	=> \&doUsage,
	'version|V'			=> \&doVersion,

	'verbose|v'			=> sub { $Carp::Verbose = 1; },

	'option|O:s%'		=> sub { $p->set($_[1] => $_[2]); },
	'permit|P=s'		=> sub { $p->permit($_[1]); },
	'forbid|F=s'		=> sub { $p->forbid($_[1]); },

	'bbcode|B'			=> sub { push @output, 'bbcode'; },
	'html|H'			=> sub { push @output, 'html'; },
	'text|T'			=> sub { push @output, 'text'; },
	'link-list|linklist|L'	=> sub { push @output, 'linklist'; },

	'output|o=s' => sub {
		foreach(split /,/, lc $_[1]) {
			if(exists $FORMATS{$_}) {
				push @output, $_;
			} else {
				die qq(Unknown output format "$_");
			}
		}
	},

	'utf-8|utf8|8' => sub {
		$enc = 'UTF-8';
	},
	'character-set|charset|encoding|e=s' => sub {
		$enc = $_[1];
	},

	'file|f=s'	=> sub { doFile $_[1] },
	'<>'		=> sub { doString $_[0] },
) or exit(1);

doString(shift) while @ARGV;



( run in 2.053 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )