App-BCVI

 view release on metacpan or  search on metacpan

bin/bcvi  view on Meta::CPAN

49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
    910 => "Unrecognised command",
);
 
my $LF = "\x0A";
 
my(
    %options, %option_name, %commands, @aliases, @installables,
    %plugin_loaded, @plugins,
);
 
run(@ARGV) unless caller();       # Don't run anything if loaded via 'require'
 
sub run {
    App::BCVI->base_init();
 
    App::BCVI->load_plugins();
 
    App::BCVI->base_class()->process_command_line(@_);
 
    exit;
}

bin/bcvi  view on Meta::CPAN

272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
sub register_option {
    my $class = shift;
    my $opt   = { @_ };
    my $key   = $opt->{name};
 
    if(!defined $key or !length $key) {
        die "Can't register option without 'name'";
    }
 
    my($package, $filename, $line) = caller();
    $opt->{provider} = "$package at $filename line $line";
    my $taken = $options{$key};
    if($taken && !$opt->{force_override}) {
        warn "option '--$key' already registered by $taken->{provider}\n";
    }
    if($opt->{alias}) {
        foreach my $a (map { s/^-+//; $_ } split /\|/, $opt->{alias}) {
            if($option_name{$a} && !$opt->{force_override}) {
                if($taken = $options{$option_name{$a}}) {
                    warn "alias '$a' already registered for option "

bin/bcvi  view on Meta::CPAN

304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
    my $class = shift;
    my $cmd   = { @_ };
    my $key   = $cmd->{name};
 
    if(!defined $key or !length $key) {
        die "Can't register command without 'name'";
    }
 
    $cmd->{dispatch_to} ||= "execute_$key";
 
    my($package, $filename, $line) = caller();
    $cmd->{provider} = "$package at $filename line $line";
    warn "option '$key' already registered by $commands{$key}->{provider}\n"
        if $commands{$key} && !$cmd->{force_override};
    $commands{$key} = $cmd;
}
 
 
sub each_option {
    my($class, $sub) = @_;

bin/bcvi  view on Meta::CPAN

353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
 
sub register_aliases {
    my $class = shift;
    push @aliases, @_;
}
 
 
sub register_installable {
    my $class = shift;
    my($package, $filename, $line) = caller();
    push @installables, $filename;
}
 
 
sub shell_aliases {
    my($self) = @_;
 
    return
        "## START-BCVI\n"
        . join("\n", map { "  $_" } @aliases)

bin/bcvi  view on Meta::CPAN

397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
        die qq{Error loading plugin "$file"\n$@\n}
    }
 
    $plugin_loaded{$key} = $file;
}
 
 
sub hook_client_class {
    my($class) = @_;
 
    my($calling_class, $calling_file) = caller();
    my $client_class = $class->client_class();
    $class->map_class(client => $calling_class);
 
    no strict 'refs';
    unshift @{"${calling_class}::ISA"}, $client_class;
    push @plugins, { class => $calling_class, file => $calling_file };
    return 1;
}
 
 
sub hook_server_class {
    my($class) = @_;
 
    my($calling_class, $calling_file) = caller();
    my $server_class = $class->server_class();
    $class->map_class(server => $calling_class);
 
    no strict 'refs';
    unshift @{"${calling_class}::ISA"}, $server_class;
    push @plugins, { class => $calling_class, file => $calling_file };
    return 1;
}



( run in 0.244 second using v1.01-cache-2.11-cpan-a9ef4e587e4 )