Changeset 162

Show
Ignore:
Timestamp:
06/05/04 00:56:02 (4 years ago)
Author:
athomas
Message:

Added log plugin, started refactor towards optionally using subclasses of CLI::Plugin for plugins.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • manage/trunk/CLI/CLI.pm

    r159 r162  
    5656                                        $file =~ s/\.pm$//; 
    5757                                        if (my $plugin = do("$args{plugins}/$file.pm")) { 
    58                                                 $self->{plugins}->{$file} = $plugin; 
    59                                                 $self->merge($plugin); 
     58                                                if (ref($plugin) eq 'HASH') { 
     59                                                        $self->{plugins}->{$file} = new CLI::Plugin(grammar => $plugin); 
     60                                                        $self->merge($plugin->{grammar}); 
     61                                                } else { 
     62                                                        $self->{plugins}->{$file} = $plugin; 
     63                                                        $self->merge($plugin->{grammar}); 
     64                                                } 
    6065                                        } else { 
    6166                                                $| = 1; 
  • manage/trunk/plugins/dns.pm

    r157 r162  
     1package CLI::Plugin::DNS; 
    12use strict; 
    23use warnings; 
     4use base qw(CLI::Plugin); 
    35 
    46my ($KEY, $SECRET, $NS) = ("", "", ""); 
     
    5860); 
    5961 
    60 # Grammar 
    61 
    62         dns => { 
    63                 add => sub { 
     62sub new(%) { 
     63my ($self, $class) = ({}, shift); 
     64my %args = @_; 
     65 
     66    $self = $class->SUPER::new(@_) or return; 
     67
     68 
     69sub initialize() { 
     70my $self = shift; 
     71
     72 
     73new CLI::Plugin::DNS( 
     74        grammar => { 
     75                dns => { 
     76                        add => sub { 
     77                        }, 
     78                        delete => { 
     79                        }, 
     80                        show => { 
     81                        }, 
     82                        # Initialise DNS module 
     83                        setup => { 
     84                        }, 
     85                        HELP => "DNS administration functions.", 
    6486                }, 
    65                 delete => { 
    66                 }, 
    67                 show => { 
    68                 }, 
    69                 # Initialise DNS module 
    70                 setup => { 
    71                 }, 
    72                 HELP => "DNS administration functions.", 
    7387        }, 
    74 }; 
     88        conf => { 
     89        }, 
     90);