GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  BASH::COMPLETION::PLUGIN (3)

.ds Aq ’

NAME

Bash::Completion::Plugin - base class for Bash::Completion plugins

CONTENTS

VERSION

version 0.008

SYNOPSIS



    ## Example plugin for xpto command
    package Bash::Completion::Plugin::XPTO;
   
    use strict;
    use warnings;
    use parent Bash::Completion::Plugin;
    use Bash::Completion::Utils qw( command_in_path );
   
    sub should_activate {
      return [grep { command_in_path(_) } (xpto)];
    }
   
   
    ## Optionally, for full control of the generated bash code
    sub generate_bash_setup {
      return q{complete -C bash-complete complete XPTO xpto};
    }
   
    ## Use plugin arguments
    sub generate_bash_setup {
      return q{complete -C bash-complete complete XPTO arg1 arg2 arg3 xpto};
    }
    ## $plugin->args will have [arg1, arg2, arg3]
   
   
    sub complete {
      my ($self, $r) = @_;
   
      my @options = (-h, --help);
      $r->candidates(prefix_match($r->word, @options));
    }
    1;



DESCRIPTION



    WARNING: the most important class for Plugin writers is the Request
    class. Please note that the Request class interface is Alpha-quality
    software, and I will update it before 1.0.



A base class for Bash::Completion plugins that provides the default implementations for the required plugin methods.

See the SYNOPSIS for an example of a plugin.

ATTRIBUTES

    args

An list reference with plugin arguments.

METHODS

    new

A basic plugin constructor. Accepts a list of key/values. Accepted keys:
args A list reference with parameters to this plugin.

    should_activate

The method should_activate() is used by the automatic setup of completion rules in the .bashrc. It should return a reference to a list of commands that the plugin is can complete.

If this method returns a reference to an empty list (the default), the plugin will not be used.

A common implementation of this method is to check the PATH for the command we want to provide completion, and return the com only if that command is found.

The Bash::Completion::Utils library has a command_in_path() that can be pretty useful here.

For example:



    sub should_activate {
      return [grep { command_in_path($_) } qw( perldoc pod )];
    }



    generate_bash_setup

This method receives the list of commands that where found by should_activate and must return a list of options to use when creating the bash complete command.

For example, if a plugin returns [qw( nospace default )], the following bash code is generated:



    complete -C bash-complete complete PluginName -o nospace -o default command



By default this method returns a reference to an empty list.

Alternatively, and for complete control, you can return a string with the entire bash code to activate the plugin.

    complete

The plugin completion logic. The class Bash::Completion will call this method with a Bash::Completion::Request object, and your code should use the Request candidates() method to set the possible completions.

The Bash::Completion::Utils library has two functions, match_perl_module() and prefix_math() that can be pretty useful here.

AUTHOR

Pedro Melo <melo@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2011 by Pedro Melo.

This is free software, licensed under:



  The Artistic License 2.0 (GPL Compatible)



Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 BASH::COMPLETION::PLUGIN (3) 2011-10-22

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.