{"id":17109576,"url":"https://github.com/monken/p5-bash-completion-plugins-cpanm","last_synced_at":"2025-03-23T21:41:34.961Z","repository":{"id":56838680,"uuid":"1379371","full_name":"monken/p5-bash-completion-plugins-cpanm","owner":"monken","description":"Bash completion for cpanm and cpanf","archived":false,"fork":false,"pushed_at":"2011-06-20T12:09:43.000Z","size":92,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-29T05:13:38.096Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/monken.png","metadata":{"files":{"readme":"README.pod","changelog":"Changes","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-02-17T18:54:33.000Z","updated_at":"2014-09-08T21:59:30.000Z","dependencies_parsed_at":"2022-08-28T23:12:36.854Z","dependency_job_id":null,"html_url":"https://github.com/monken/p5-bash-completion-plugins-cpanm","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monken%2Fp5-bash-completion-plugins-cpanm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monken%2Fp5-bash-completion-plugins-cpanm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monken%2Fp5-bash-completion-plugins-cpanm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monken%2Fp5-bash-completion-plugins-cpanm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/monken","download_url":"https://codeload.github.com/monken/p5-bash-completion-plugins-cpanm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245175323,"owners_count":20572781,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T16:23:39.178Z","updated_at":"2025-03-23T21:41:34.912Z","avatar_url":"https://github.com/monken.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"package Bash::Completion::Plugins::cpanm;\n\n# ABSTRACT: Bash completion for cpanm and cpanf\nuse strict;\nuse warnings;\nuse base 'Bash::Completion::Plugin';\n\nuse HTTP::Request::Common qw(POST);\nuse LWP::UserAgent;\nuse JSON;\n\nuse Bash::Completion::Utils qw( command_in_path );\n\nsub should_activate {\n    my @commands = qw( cpanm cpanf cpan );\n    return [ grep { command_in_path($_) } @commands ];\n}\n\nsub generate_bash_setup { return [qw( nospace default )] }\n\nsub complete {\n    my ( $class, $req ) = @_;\n    my $ua = LWP::UserAgent-\u003enew;\n    ( my $key = $req-\u003eword ) =~ s/::?/-/g;\n\n    #$key =~ s/-$//g;\n    my $res = $ua-\u003erequest(\n        POST 'http://api.metacpan.org/release/_search',\n        Content =\u003e encode_json(\n            {   size   =\u003e 1000,\n                fields =\u003e ['distribution'],\n                sort   =\u003e ['distribution'],\n                query  =\u003e {\n                    filtered =\u003e {\n                        query  =\u003e { match_all =\u003e {} },\n                        filter =\u003e {\n                            and =\u003e [\n                                { prefix =\u003e { 'release.distribution' =\u003e $key } },\n                                { term   =\u003e { status        =\u003e 'latest' } }\n                            ]\n                        }\n                    }\n                }\n            }\n        )\n    );\n    eval {\n        my $json = decode_json( $res-\u003econtent );\n        $req-\u003ecandidates('') unless ( $json-\u003e{hits} );\n        my @candidates;\n        my $exact_match = 0;\n        for ( @{ $json-\u003e{hits}-\u003e{hits} } ) {\n            my $dist = $_-\u003e{fields}-\u003e{distribution};\n            $exact_match = 1 if ( $key eq $dist );\n            $key  =~ s/^(.*)\\-.*?$/$1-/;\n            $dist =~ s/^\\Q$key\\E// if ( $key =~ /-/ );\n            $dist =~ s/-.*?$/::/g;\n            push( @candidates, $dist );\n        }\n        $req-\u003ecandidates(@candidates)\n            unless ( $exact_match \u0026\u0026 @candidates == 1 );\n    };\n}\n\n1;\n\n__END__\n\n=head1 SYNOPSIS\n\n  $ cpanm MooseX::      \n  Display all 121 possibilities? (y or n)\n  ABC                     Declare                 Object::\n  APIRole                 DeepAccessors           OneArgNew\n  AbstractFactory         Documenter              POE\n  Accessors::             Emulate::               Param\n  Aliases                 Error::                 Params::\n  Alien                   FSM                     Plaggerize\n  AlwaysCoerce            FileAttribute           Policy::\n  App::                   File_or_DB::            Privacy\n  Async                   FollowPBP               PrivateSetters\n  Atom                    Getopt                  Q4MLog\n  Attribute::             Getopt::                RelatedClassRoles\n  AttributeCloner         GlobRef                 Role::\n  AttributeDefaults       Has::                   Runnable\n  AttributeHelpers        HasDefaults             Runnable::\n  AttributeIndexes        IOC                     Scaffold\n  AttributeInflate        InsideOut               SemiAffordanceAccessor\n  ...\n\n=head1 DESCRIPTION\n\nL\u003cBash::Completion\u003e profile for C\u003ccpanm\u003e, C\u003ccpanf\u003e and C\u003ccpan\u003e.\n\nSimply add this line to your C\u003c.bashrc\u003e or C\u003c.bash_profile\u003e file:\n\n source setup-bash-complete\n\nor run it manually in a bash session.\n\n=head1 METHODS\n\n=head2 complete\n\nQueries C\u003chttp://api.metacpan.org\u003e for distributions that match the given name.\nLimits the number of results to 1000. Some namespaces might not appear if there\nare more than 1000 results for a given query.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonken%2Fp5-bash-completion-plugins-cpanm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmonken%2Fp5-bash-completion-plugins-cpanm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonken%2Fp5-bash-completion-plugins-cpanm/lists"}