[Bps-public-commit] r13521 - in Shipwright/trunk: lib/Shipwright/Script
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Sat Jun 21 03:05:21 EDT 2008
Author: sunnavy
Date: Sat Jun 21 03:05:20 2008
New Revision: 13521
Modified:
Shipwright/trunk/ (props changed)
Shipwright/trunk/lib/Shipwright/Script/Flags.pm
Log:
r13607 at sunnavys-mb: sunnavy | 2008-06-21 01:33:32 +0800
refactor a bit, texts improved
Modified: Shipwright/trunk/lib/Shipwright/Script/Flags.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Script/Flags.pm (original)
+++ Shipwright/trunk/lib/Shipwright/Script/Flags.pm Sat Jun 21 03:05:20 2008
@@ -47,22 +47,8 @@
unless ( defined $self->add || defined $self->delete || defined $self->set )
{
- if ( $self->mandatary ) {
- if ( $flags->{__mandatary}{$name} ) {
- print join( ', ', @{ $flags->{__mandatary}{$name} } ), "\n";
- }
- else {
- print "$name is not a valid mandatary name\n";
- }
- }
- else {
- if ( $flags->{$name} ) {
- print join( ', ', @{ $flags->{$name} } ), "\n";
- }
- else {
- print "$name is not set flags\n";
- }
- }
+ # show without change
+ $self->_show_flags( $flags );
return;
}
@@ -96,15 +82,40 @@
}
$shipwright->backend->flags($flags);
+ $self->_show_flags( $flags );
+}
+
+
+sub _show_flags {
+ my $self = shift;
+ my $flags = shift;
+ my $name = $self->name;
+
+ my $changed;
+ $changed = 1 if $self->add || $self->delete || $self->set;
if ( $self->mandatary ) {
- print "set mandatary flags with success, current flags for $name is "
- . join( ', ', @{ $flags->{__mandatary}{$name} } ) . "\n";
+ print "set mandatary flags with success\n" if $changed;
+ print "mandatary flags of $name is ";
+ if ( @{$flags->{__mandatary}{$name} || [] } ) {
+ print join( ', ', @{ $flags->{__mandatary}{$name} } ) . "\n";
+ }
+ else {
+ print "*nothing*\n";
+ }
}
else {
- print "set flags with success, current flags for $name is "
- . join( ', ', @{ $flags->{$name} } ) . "\n";
+ print "set flags with success\n" if $changed;
+ print "flags of $name is ";
+ if ( @{$flags->{$name} || [] } ) {
+ print join( ', ', @{ $flags->{$name} } ) . "\n";
+ }
+ else {
+ print "*nothing*\n";
+ }
}
+
+
}
1;
More information about the Bps-public-commit
mailing list