{"id":19640431,"url":"https://github.com/kentnl/dist-zilla-util-currentcmd","last_synced_at":"2026-06-10T06:45:24.067Z","repository":{"id":17389483,"uuid":"20161746","full_name":"kentnl/Dist-Zilla-Util-CurrentCmd","owner":"kentnl","description":"Attempt to determine the current command Dist::Zilla is running under","archived":false,"fork":false,"pushed_at":"2017-03-03T11:39:17.000Z","size":122,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-09T18:57:25.358Z","etag":null,"topics":["dist-zilla","perl"],"latest_commit_sha":null,"homepage":null,"language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kentnl.png","metadata":{"files":{"readme":"README.mkdn","changelog":"Changes","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-05-25T18:12:48.000Z","updated_at":"2017-03-03T10:44:47.000Z","dependencies_parsed_at":"2022-09-24T16:00:23.977Z","dependency_job_id":null,"html_url":"https://github.com/kentnl/Dist-Zilla-Util-CurrentCmd","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kentnl%2FDist-Zilla-Util-CurrentCmd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kentnl%2FDist-Zilla-Util-CurrentCmd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kentnl%2FDist-Zilla-Util-CurrentCmd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kentnl%2FDist-Zilla-Util-CurrentCmd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kentnl","download_url":"https://codeload.github.com/kentnl/Dist-Zilla-Util-CurrentCmd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240947648,"owners_count":19883030,"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":["dist-zilla","perl"],"created_at":"2024-11-11T14:05:47.698Z","updated_at":"2026-06-10T06:45:24.021Z","avatar_url":"https://github.com/kentnl.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NAME\n\nDist::Zilla::Util::CurrentCmd - Attempt to determine the current command Dist::Zilla is running under.\n\n# VERSION\n\nversion 0.002004\n\n# SYNOPSIS\n\n    use Dist::Zilla::Util::CurrentCmd qw(current_cmd);\n\n    ...\n\n    if ( is_install() ) {\n      die \"This plugin hates installing things for some reason!\"\n    }\n    if ( is_build() ) {\n      print \"I Love you man\\n\";\n    }\n    if ( current_cmd() eq 'run' ) {\n      die \"RUN THE OTHER WAY\"\n    }\n\n# DESCRIPTION\n\nThis module exists in case you are absolutely certain you want to have different behaviors for either a plugin, or a bundle, to\ntrigger on ( or off ) a specific phase.\n\nUsually, this is a bad idea, and the need to do this suggests a poor choice of work-flow to begin with.\n\nThat said, this utility is _probably_ more useful in a bundle than in a plugin, in that it will be slightly more optimal than\nsay, having an `ENV` flag to control this difference.\n\n# FUNCTIONS\n\n## `current_cmd`\n\nReturns the name of the of the **first** `command` entry in the `caller` stack that matches\n\n    /\\ADist::Zilla::App::Command::(.*)::([^:\\s]+)\\z/msx\n\nFor instance:\n\n    Dist::Zilla::App::Command::build::execute -\u003e\n        build\n\n## `is_build`\n\nConvenience shorthand for `current_cmd() eq 'build'`\n\n## `is_install`\n\nConvenience shorthand for `current_cmd() eq 'install'`\n\n## `as_cmd`\n\nInternals wrapper to lie to code operating in the callback that the `current_cmd` is.\n\n    as_cmd('install' =\u003e sub {\n\n        is_install(); # true\n\n    });\n\n# CAVEATS\n\nUser beware, this code is both hackish and new, and relies on using `caller` to determine which\n`Dist::Zilla::App::Command::` we are running under.\n\nThere may be conditions that there are no `Command`s in the `caller` stack which meet this definition, or the _first_ such\nthing may be a misleading representation of what is actually running.\n\nAnd there's a degree of uncertainty of reliability, because I haven't yet devised reliable ways of testing it that don't\ninvolve invoking `dzil` ( which is problematic on testers where `Dist::Zilla` is in `@INC` but `dzil` is not in\n`ENV{PATH}` )\n\nTo that extent, I don't even know for sure if this module works yet, or if it works in a bundle, or if it works in all\ncommands, or if it works under `Dist::Zilla::App::Tester` as expected.\n\n# AUTHOR\n\nKent Fredric \u003ckentnl@cpan.org\u003e\n\n# COPYRIGHT AND LICENSE\n\nThis software is copyright (c) 2017 by Kent Fredric \u003ckentfredric@gmail.com\u003e.\n\nThis is free software; you can redistribute it and/or modify it under\nthe same terms as the Perl 5 programming language system itself.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkentnl%2Fdist-zilla-util-currentcmd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkentnl%2Fdist-zilla-util-currentcmd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkentnl%2Fdist-zilla-util-currentcmd/lists"}