perlpunk / App-Spec-p5

Writing command line apps made easy
Other
23 stars 9 forks source link

Rename App::Spec::Completion::Bash to ...::bash #9

Open dolmen opened 8 years ago

dolmen commented 8 years ago

Rename App::Spec::Completion::Bash to App::Spec::Completion::bash and App::Spec::Completion::Zsh to App::Spec::Completion::zsh. That will allow extension and simplify App::Spec::generate_completion:

sub generate_completion {
    my ($self, %args) = @_;
    my $shell = delete $args{shell};

    require "App/Spec/Completion/$shell.pm";
    "App::Spec::Completion::$shell"->new({ spec => $self })->generate_completion(%args)
}
dolmen commented 8 years ago

As a side note, this is the approach I'm using in my Angel's Prompt project that has shell-specific features.

dolmen commented 8 years ago

This approach also allows the startup of the program to be faster as the shell plugin will only be loaded when used (the use App::Spec::Completion::* at the beginning of App::Spec must be removed as they are replaced by the require).

perlpunk commented 8 years ago

Thanks, I'm planning some renaming (and lazy loading) anyway, so that it easier to have plugins. I thought about App::Spec::Generator::Completion::*

angel-PS1 looks interesting =)

perlpunk commented 8 years ago

I would actually like to move the completion and pod generator to App::AppSpec, so that App::Spec(::Run) is the only thing you need to install for running the app.