Changeset 11 for client


Ignore:
Timestamp:
11/21/10 13:17:09 (14 years ago)
Author:
nanardon
Message:
  • improve admin part
File:
1 edited

Legend:

Unmodified
Added
Removed
  • client/trunk/lib/Sophie/Cli.pm

    r4 r11  
    2828            prompt => sub { 
    2929                sprintf('%s - %s - %s > ', 
    30                     $_[0]->{dist}, 
    31                     $_[0]->{vers}, 
    32                     $_[0]->{arch}, 
    33                 ); 
    34             }, 
    35             dist => $dist, 
    36             vers => $vers, 
    37             arch => $arch, 
     30                    $_[0]->{dist}{distribution}, 
     31                    $_[0]->{dist}{release}, 
     32                    $_[0]->{dist}{arch}, 
     33                ); 
     34            }, 
     35            dist => { 
     36                distribution => $dist, 
     37                release => $vers, 
     38                arch => $arch, 
     39            }, 
    3840        }, 
    3941        $base, 
     
    4446                my ($self) = @_; 
    4547 
    46                 my $res = $self->xmlreq('distrib.struct', $self->{dist}, 
    47                     $self->{vers}, 
    48                     $self->{arch}); 
     48                my $res = $self->xmlreq('distrib.struct', 
     49                    $self->{dist}, 
     50                ); 
    4951                print $OUT join ('', map { "$_->{label}\n" } @{ $res->value }); 
    5052            } 
     
    5557            code => sub { 
    5658                my ($self, $media, $path) = @_; 
    57                 my $res = $self->xmlreq('admin.media_path', $self->{dist}, 
    58                     $self->{vers}, 
    59                     $self->{arch}, 
     59                my $res = $self->xmlreq('admin.media_path', 
     60                    $self->{dist}, 
    6061                    $media, 
    6162                    $path, 
     
    6768                    return (<$start*>) 
    6869                } else { 
    69                 my $res = $self->xmlreq('distrib.struct', $self->{dist}, 
    70                     $self->{vers}, 
    71                     $self->{arch}); 
     70                my $res = $self->xmlreq('distrib.struct', 
     71                    $self->{dist}, 
     72                ); 
    7273                return map { $_->{label} } @{ $res->value }; 
    7374                } 
     
    7576        } 
    7677    ); 
     78    $env->add_func('listpath', { 
     79            code => sub { 
     80                my ($self, $media) = @_; 
     81                my $res = $self->xmlreq('admin.list_path', 
     82                    $self->{dist}, 
     83                    $media, 
     84                ); 
     85                print $OUT join ('', map { "$_\n" } @{ $res->value }); 
     86            }, 
     87            completion => sub { 
     88                my ($self, $start) = @_; 
     89                my $res = $self->xmlreq('distrib.struct', 
     90                    $self->{dist}, 
     91                ); 
     92                return map { $_->{label} } @{ $res->value }; 
     93            }, 
     94        } 
     95    ); 
    7796    $env->add_func('addmedia', { 
    7897            code => sub { 
    7998                my ($self, $media, $group) = @_; 
    80                 my $res = $self->xmlreq('admin.add_media', $self->{dist}, 
    81                     $self->{vers}, 
    82                     $self->{arch}, 
    83                     $media, 
    84                     $group, 
     99                my $res = $self->xmlreq('admin.add_media',$self->{dist}, 
     100                    { dist_label => $media, 
     101                      group_label => $group }, 
    85102                ); 
    86103                print $OUT join ('', map { "$_->{label}\n" } @{ $res->value }); 
     
    88105            completion => sub { 
    89106                my ($self) = @_; 
    90                 my $res = $self->xmlreq('distrib.struct', $self->{dist}, 
    91                     $self->{vers}, 
    92                     $self->{arch}); 
     107                my $res = $self->xmlreq('distrib.struct', 
     108                    $self->{dist}, 
     109                ); 
    93110                return map { $_->{label} } @{ $res->value }; 
    94111            }, 
     
    108125            code => sub { 
    109126                my ($self, $dist, $ver, $arch) = @_; 
     127                if (!($dist && $ver && $arch)) { 
     128                    print $OUT "missing argument\n"; 
     129                    return; 
     130                } 
    110131                denv($self->base, $dist, $ver, $arch)->cli(); 
    111132            }, 
Note: See TracChangeset for help on using the changeset viewer.