Update to current Perl
This commit is contained in:
parent
ebd46d86d4
commit
3cc88f8150
57 changed files with 11638 additions and 665 deletions
70
lib/WGDev/Command/Guid.pm
Normal file
70
lib/WGDev/Command/Guid.pm
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
package WGDev::Command::Guid;
|
||||
# ABSTRACT: Generates GUIDs via WebGUI's $session->id->generate API
|
||||
use strict;
|
||||
use warnings;
|
||||
use 5.008008;
|
||||
|
||||
use parent qw(WGDev::Command::Base);
|
||||
|
||||
sub config_options {
|
||||
return qw(
|
||||
number|n=i
|
||||
dashes!
|
||||
toHex
|
||||
);
|
||||
}
|
||||
|
||||
sub process {
|
||||
my $self = shift;
|
||||
my $wgd = $self->wgd;
|
||||
|
||||
my $session = $wgd->session();
|
||||
my $id = $session->id;
|
||||
|
||||
if ( $self->option('toHex') ) {
|
||||
foreach my $guid ( $self->arguments ) {
|
||||
printf "%s : %s\n", $guid, $id->toHex($guid);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
my $number = $self->option('number') || 1;
|
||||
$self->set_option_default( dashes => 1 );
|
||||
|
||||
for ( 1 .. $number ) {
|
||||
my $guid = $id->generate();
|
||||
if ( !$self->option('dashes') && $guid =~ /[-_]/msx ) {
|
||||
redo;
|
||||
}
|
||||
print "$guid\n";
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
wgd guid [-n <quantity>] [--no-dashes]
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Generates GUIDs via WebGUI's C<$session->id->generate> API. Optionally
|
||||
excludes GUIDs with dashes (for easy double-click copy/pasting).
|
||||
|
||||
=head1 OPTIONS
|
||||
|
||||
=over 8
|
||||
|
||||
=item C<-n> C<--number>
|
||||
|
||||
Number of GUIDs to generate. Defaults to 1.
|
||||
|
||||
=item C<--[no-]dashes>
|
||||
|
||||
Whether or not to filter GUIDs containing dashes (for easy double-click copy/pasting)
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue