Term-Shell-0.13000755000764000764 014134244454 13713 5ustar00shlomifshlomif000000000000README100644000764000764 56114134244454 14636 0ustar00shlomifshlomif000000000000Term-Shell-0.13This archive contains the distribution Term-Shell, version 0.13: A simple command-line shell framework. This software is copyright (c) 2001 by Neil Watkiss. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. This README file was generated by Dist::Zilla::Plugin::Readme v6.024. Changes100644000764000764 744014134244454 15274 0ustar00shlomifshlomif000000000000Term-Shell-0.130.13 2021-10-21 - Fix "Discrepancy between distro and Shell.pm version number" - https://github.com/shlomif/Term-Shell/pull/4 - Thanks to @EmilianoBruni . 0.12 2020-10-14 - Rebuild for new dist.ini / weaver.ini / etc. deps 0.11 2019-04-30 - Apply https://github.com/shlomif/Term-Shell/pull/3 - Fix aliases. - Add tidyall, TestCount, PerlCritic, PerlTidy checks. 0.10 2018-12-22 - Convert dist.ini to @SHLOMIF . - Add .travis.yml / Travis-CI - https://github.com/shlomif/Term-Shell/pull/1 - Thanks to https://github.com/jluis - Bump minimal required version of perl to 5.014. - https://github.com/shlomif/supporting-older-perl5-releases/blob/master/about-supporting-older-perl5-releases.pod 0.09 2016-04-13 - Fix the copyright holder, license and year in dist.ini/meta-data. - It should be Neil Watkiss / Perl 5 / 2001 - https://rt.cpan.org/Ticket/Display.html?id=113735 - Thanks to KENTNL for the report. 0.08 2016-04-13 - Remove stray Build/_build artifacts from the distribution: - https://rt.cpan.org/Ticket/Display.html?id=113730 - Thanks to KENTNL - Fix the link to the bugtracker, add META.json, and supply a meta-data "Provides" section. - https://rt.cpan.org/Ticket/Display.html?id=113731 - Thanks to KENTNL 0.07 2015-12-30 - Convert to Dist-Zilla. - Add scripts/tag-release.pl - Skip a failing test file ( t/03catchsmry.t ) on Windows: - https://rt.cpan.org/Ticket/Display.html?id=40771 - https://rt.cpan.org/Ticket/Display.html?id=110555 0.06 2014-04-10 - Consistent versioning (CPANTS). 0.05 2014-01-31 - Minimum version of perl (CPANTS). - Add a LICENSE file (CPANTS). - Add t/style-trailing-space.t and remove trailing whitespace. 0.04 2013-06-03 - Add an explicit version to Term::Shell::OnScopeLeave. - to settle the PAUSE indexer. - Convert t/01require.t to Test::More and strict/warnings. - Convert t/02default.t to Test::More and strict/warnings. - Add "use warnings;" to t/03catchsmry.t . 0.03 2012-10-14 - Moved test.pl under examples so it won't interfere with the building and testing. - See https://rt.cpan.org/Public/Bug/Display.html?id=40771 - Thanks to CHORNY and praveenkumar for the reports. - Correct the POD. - Add t/pod.t . - Convert the distribution to Build.PL . 0.02 2007-02-24 - Fix CPAN bug id 2463: help now unconditionally calls $o->summary() 0.01 2002-01-25 - Documentation updates - Read the README - Added cmd_prefix() and cmd_suffix() - Reorganized the handlers to make more sense, given the above - Preparing for initial release - Lots of documentation additions - Added a README - Access to the Term::ReadLine object - Added precmd(), postcmd(), preloop(), postloop(), init(), and fini() callbacks. - Added a cmd() method, which parses and runs the command-line you pass in. Used internally by cmdloop(). - Added some more documentation and features to Term::Shell - Remove 'quit' alias for 'exit' in Term::Shell. Smaller is better. - Changed default prompt to 'shell> '. - Added and documented the prompt_user() method. - Added the prompt_user() method to the interactive test. - Added the comp_() sub, to override the top-level command-completion routine. - Fixed a bug which prevented completion from working - Added catch_*() methods to catch missing handlers. - Added an example called psh.pl (Perl SHell) - Fixed order of comp_*() handlers to match Term::ReadLine::Perl - Added tests and documentation. Needs more doc. - Adding initial version of Term::Shell to the repository. Needs documentation. LICENSE100644000764000764 5013114134244454 15021 0ustar00shlomifshlomif000000000000Term-Shell-0.13Terms of Perl itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" ---------------------------------------------------------------------------- GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS ---------------------------------------------------------------------------- The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End dist.ini100644000764000764 162214134244454 15441 0ustar00shlomifshlomif000000000000Term-Shell-0.13name = Term-Shell author = Shlomi Fish license = Perl_5 copyright_holder = Neil Watkiss copyright_year = 2001 version = 0.13 [@Filter] -bundle = @SHLOMIF -remove = AutoPrereqs -remove = MakeMaker -remove = License -remove = PodCoverageTests dist = Term-Shell bugtracker_web = http://rt.cpan.org/NoAuth/Bugs.html?Dist=Term-Shell bugtracker_mailto = bug-term-shell@rt.cpan.org repository_url = git://git@github.com:shlomif/Term-Shell.git repository_web = https://github.com/shlomif/Term-Shell repository_type = git [AutoPrereqs] skip = ^Term::InKey$ skip = ^Term::Screen$ skip = ^Term::Size$ skip = ^Win32::Console$ [Keywords] keyword = console keyword = readline keyword = shell keyword = term keyword = terminal [Prereqs / Runtime] -phase = runtime Getopt::Long = 2.36 [Test::Kwalitee] [Test::TidyAll] ; authordep Pod::Weaver::PluginBundle::SHLOMIF ; authordep Code::TidyAll::Plugin::TestCount META.yml100644000764000764 2731614134244454 15276 0ustar00shlomifshlomif000000000000Term-Shell-0.13--- abstract: 'A simple command-line shell framework.' author: - 'Shlomi Fish ' build_requires: File::Spec: '0' IO::Handle: '0' IPC::Open3: '0' Module::Build: '0.28' Test::More: '0.88' base: '0' configure_requires: Module::Build: '0.28' dynamic_config: 0 generated_by: 'Dist::Zilla version 6.024, CPAN::Meta::Converter version 2.150010' keywords: - console - readline - shell - term - terminal license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Term-Shell provides: Term::Shell: file: lib/Term/Shell.pm version: '0.13' Term::Shell::OnScopeLeave: file: lib/Term/Shell.pm version: '0.13' requires: Data::Dumper: '0' File::Temp: '0' Getopt::Long: '2.36' IO::Select: '0' Term::ReadKey: '0' Term::ReadLine: '0' Text::Autoformat: '0' perl: '5.014' strict: '0' warnings: '0' resources: bugtracker: http://rt.cpan.org/NoAuth/Bugs.html?Dist=Term-Shell homepage: http://metacpan.org/release/Term-Shell repository: git://git@github.com:shlomif/Term-Shell.git version: '0.13' x_Dist_Zilla: perl: version: '5.032001' plugins: - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: test type: requires name: '@Filter/TestMoreDoneTesting' version: '6.024' - class: Dist::Zilla::Plugin::ExecDir name: '@Filter/ExecDir' version: '6.024' - class: Dist::Zilla::Plugin::GatherDir config: Dist::Zilla::Plugin::GatherDir: exclude_filename: [] exclude_match: [] follow_symlinks: 0 include_dotfiles: 0 prefix: '' prune_directory: [] root: . name: '@Filter/GatherDir' version: '6.024' - class: Dist::Zilla::Plugin::ManifestSkip name: '@Filter/ManifestSkip' version: '6.024' - class: Dist::Zilla::Plugin::MetaYAML name: '@Filter/MetaYAML' version: '6.024' - class: Dist::Zilla::Plugin::PruneCruft name: '@Filter/PruneCruft' version: '6.024' - class: Dist::Zilla::Plugin::Readme name: '@Filter/Readme' version: '6.024' - class: Dist::Zilla::Plugin::RunExtraTests config: Dist::Zilla::Role::TestRunner: default_jobs: 1 name: '@Filter/RunExtraTests' version: '0.029' - class: Dist::Zilla::Plugin::ShareDir name: '@Filter/ShareDir' version: '6.024' - class: Dist::Zilla::Plugin::CheckChangesHasContent name: '@Filter/CheckChangesHasContent' version: '0.011' - class: Dist::Zilla::Plugin::ConfirmRelease name: '@Filter/ConfirmRelease' version: '6.024' - class: Dist::Zilla::Plugin::Manifest name: '@Filter/Manifest' version: '6.024' - class: Dist::Zilla::Plugin::MetaConfig name: '@Filter/MetaConfig' version: '6.024' - class: Dist::Zilla::Plugin::MetaJSON name: '@Filter/MetaJSON' version: '6.024' - class: Dist::Zilla::Plugin::MetaProvides::Package config: Dist::Zilla::Plugin::MetaProvides::Package: finder_objects: - class: Dist::Zilla::Plugin::FinderCode name: '@Filter/MetaProvides::Package/AUTOVIV/:InstallModulesPM' version: '6.024' include_underscores: 0 Dist::Zilla::Role::MetaProvider::Provider: $Dist::Zilla::Role::MetaProvider::Provider::VERSION: '2.002004' inherit_missing: '1' inherit_version: '1' meta_noindex: '1' Dist::Zilla::Role::ModuleMetadata: Module::Metadata: '1.000037' version: '0.006' name: '@Filter/MetaProvides::Package' version: '2.004003' - class: Dist::Zilla::Plugin::MetaResources name: '@Filter/MetaResources' version: '6.024' - class: Dist::Zilla::Plugin::ModuleBuild config: Dist::Zilla::Role::TestRunner: default_jobs: 1 name: '@Filter/ModuleBuild' version: '6.024' - class: Dist::Zilla::Plugin::PkgVersion name: '@Filter/PkgVersion' version: '6.024' - class: Dist::Zilla::Plugin::PodSyntaxTests name: '@Filter/PodSyntaxTests' version: '6.024' - class: Dist::Zilla::Plugin::Test::Compile config: Dist::Zilla::Plugin::Test::Compile: bail_out_on_fail: '0' fail_on_warning: author fake_home: 0 filename: t/00-compile.t module_finder: - ':InstallModules' needs_display: 0 phase: test script_finder: - ':PerlExecFiles' skips: [] switch: [] name: '@Filter/Test::Compile' version: '2.058' - class: Dist::Zilla::Plugin::Test::CPAN::Changes config: Dist::Zilla::Plugin::Test::CPAN::Changes: changelog: Changes name: '@Filter/Test::CPAN::Changes' version: '0.012' - class: Dist::Zilla::Plugin::Test::EOL config: Dist::Zilla::Plugin::Test::EOL: filename: xt/author/eol.t finder: - ':ExecFiles' - ':InstallModules' - ':TestFiles' trailing_whitespace: 1 name: '@Filter/Test::EOL' version: '0.19' - class: Dist::Zilla::Plugin::Test::NoTabs config: Dist::Zilla::Plugin::Test::NoTabs: filename: xt/author/no-tabs.t finder: - ':InstallModules' - ':ExecFiles' - ':TestFiles' name: '@Filter/Test::NoTabs' version: '0.15' - class: Dist::Zilla::Plugin::Test::TrailingSpace name: '@Filter/Test::TrailingSpace' version: ~ - class: Dist::Zilla::Plugin::TestRelease name: '@Filter/TestRelease' version: '6.024' - class: Dist::Zilla::Plugin::PodWeaver config: Dist::Zilla::Plugin::PodWeaver: finder: - ':InstallModules' - ':ExecFiles' plugins: - class: Pod::Weaver::Plugin::SingleEncoding name: '@SHLOMIF/SingleEncoding' version: '4.018' - class: Pod::Weaver::Plugin::WikiDoc name: '@SHLOMIF/WikiDoc' version: '0.093004' - class: Pod::Weaver::Plugin::EnsurePod5 name: '@CorePrep/EnsurePod5' version: '4.018' - class: Pod::Weaver::Plugin::H1Nester name: '@CorePrep/H1Nester' version: '4.018' - class: Pod::Weaver::Section::Generic name: '@SHLOMIF/Name' version: '4.018' - class: Pod::Weaver::Section::Version name: '@SHLOMIF/Version' version: '4.018' - class: Pod::Weaver::Section::Region name: '@SHLOMIF/Prelude' version: '4.018' - class: Pod::Weaver::Section::Generic name: '@SHLOMIF/Synopsis' version: '4.018' - class: Pod::Weaver::Section::Generic name: '@SHLOMIF/Description' version: '4.018' - class: Pod::Weaver::Section::Generic name: '@SHLOMIF/Usage' version: '4.018' - class: Pod::Weaver::Section::Generic name: '@SHLOMIF/Overview' version: '4.018' - class: Pod::Weaver::Section::Generic name: '@SHLOMIF/Stability' version: '4.018' - class: Pod::Weaver::Section::Collect name: Requirements version: '4.018' - class: Pod::Weaver::Section::Collect name: Attributes version: '4.018' - class: Pod::Weaver::Section::Collect name: Constructors version: '4.018' - class: Pod::Weaver::Section::Collect name: Methods version: '4.018' - class: Pod::Weaver::Section::Collect name: Functions version: '4.018' - class: Pod::Weaver::Section::Leftovers name: '@SHLOMIF/Leftovers' version: '4.018' - class: Pod::Weaver::Section::Region name: '@SHLOMIF/postlude' version: '4.018' - class: Pod::Weaver::Section::Support name: '@SHLOMIF/Support' version: '1.013' - class: Pod::Weaver::Section::Authors name: '@SHLOMIF/Authors' version: '4.018' - class: Pod::Weaver::Section::Bugs name: '@SHLOMIF/Bugs' version: '4.018' - class: Pod::Weaver::Section::Contributors name: '@SHLOMIF/Contributors' version: '0.009' - class: Pod::Weaver::Section::Legal name: '@SHLOMIF/Legal' version: '4.018' - class: Pod::Weaver::Plugin::Transformer name: '@SHLOMIF/List' version: '4.018' name: '@Filter/PodWeaver' version: '4.009' - class: Dist::Zilla::Plugin::UploadToCPAN name: '@Filter/UploadToCPAN' version: '6.024' - class: Dist::Zilla::Plugin::AutoPrereqs name: AutoPrereqs version: '6.024' - class: Dist::Zilla::Plugin::Keywords config: Dist::Zilla::Plugin::Keywords: keywords: - console - readline - shell - term - terminal name: Keywords version: '0.007' - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: runtime type: requires name: Runtime version: '6.024' - class: Dist::Zilla::Plugin::Test::Kwalitee config: Dist::Zilla::Plugin::Test::Kwalitee: filename: xt/release/kwalitee.t skiptest: [] name: Test::Kwalitee version: '2.12' - class: Dist::Zilla::Plugin::Test::TidyAll name: Test::TidyAll version: '0.04' - class: Dist::Zilla::Plugin::FinderCode name: ':InstallModules' version: '6.024' - class: Dist::Zilla::Plugin::FinderCode name: ':IncModules' version: '6.024' - class: Dist::Zilla::Plugin::FinderCode name: ':TestFiles' version: '6.024' - class: Dist::Zilla::Plugin::FinderCode name: ':ExtraTestFiles' version: '6.024' - class: Dist::Zilla::Plugin::FinderCode name: ':ExecFiles' version: '6.024' - class: Dist::Zilla::Plugin::FinderCode name: ':PerlExecFiles' version: '6.024' - class: Dist::Zilla::Plugin::FinderCode name: ':ShareFiles' version: '6.024' - class: Dist::Zilla::Plugin::FinderCode name: ':MainModule' version: '6.024' - class: Dist::Zilla::Plugin::FinderCode name: ':AllFiles' version: '6.024' - class: Dist::Zilla::Plugin::FinderCode name: ':NoFiles' version: '6.024' - class: Dist::Zilla::Plugin::FinderCode name: '@Filter/MetaProvides::Package/AUTOVIV/:InstallModulesPM' version: '6.024' zilla: class: Dist::Zilla::Dist::Builder config: is_trial: '0' version: '6.024' x_generated_by_perl: v5.32.1 x_serialization_backend: 'YAML::Tiny version 1.73' x_spdx_expression: 'Artistic-1.0-Perl OR GPL-1.0-or-later' MANIFEST100644000764000764 77414134244454 15115 0ustar00shlomifshlomif000000000000Term-Shell-0.13# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.024. Build.PL Changes LICENSE MANIFEST MANIFEST.SKIP META.json META.yml README README.md dist.ini examples/old-test.pl examples/psh.pl lib/Term/Shell.pm scripts/bump-version-number.pl scripts/tag-release.pl t/00-compile.t t/01require.t t/02default.t t/03catchsmry.t weaver.ini xt/author/eol.t xt/author/no-tabs.t xt/author/pod-syntax.t xt/author/tidyall.t xt/release/cpan-changes.t xt/release/kwalitee.t xt/release/trailing-space.t Build.PL100644000764000764 255714134244454 15301 0ustar00shlomifshlomif000000000000Term-Shell-0.13 # This file was automatically generated by Dist::Zilla::Plugin::ModuleBuild v6.024. use strict; use warnings; use Module::Build 0.28; my %module_build_args = ( "build_requires" => { "Module::Build" => "0.28" }, "configure_requires" => { "Module::Build" => "0.28" }, "dist_abstract" => "A simple command-line shell framework.", "dist_author" => [ "Shlomi Fish " ], "dist_name" => "Term-Shell", "dist_version" => "0.13", "license" => "perl", "module_name" => "Term::Shell", "recursive_test_files" => 1, "requires" => { "Data::Dumper" => 0, "File::Temp" => 0, "Getopt::Long" => "2.36", "IO::Select" => 0, "Term::ReadKey" => 0, "Term::ReadLine" => 0, "Text::Autoformat" => 0, "perl" => "5.014", "strict" => 0, "warnings" => 0 }, "test_requires" => { "File::Spec" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Test::More" => "0.88", "base" => 0 } ); my %fallback_build_requires = ( "File::Spec" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Module::Build" => "0.28", "Test::More" => "0.88", "base" => 0 ); unless ( eval { Module::Build->VERSION(0.4004) } ) { delete $module_build_args{test_requires}; $module_build_args{build_requires} = \%fallback_build_requires; } my $build = Module::Build->new(%module_build_args); $build->create_build_script; README.md100644000764000764 10414134244454 15226 0ustar00shlomifshlomif000000000000Term-Shell-0.13Sources for [Term-Shell](https://metacpan.org/release/Term-Shell) . META.json100644000764000764 4522214134244454 15442 0ustar00shlomifshlomif000000000000Term-Shell-0.13{ "abstract" : "A simple command-line shell framework.", "author" : [ "Shlomi Fish " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 6.024, CPAN::Meta::Converter version 2.150010", "keywords" : [ "console", "readline", "shell", "term", "terminal" ], "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Term-Shell", "prereqs" : { "build" : { "requires" : { "Module::Build" : "0.28" } }, "configure" : { "requires" : { "Module::Build" : "0.28" } }, "develop" : { "requires" : { "Test::CPAN::Changes" : "0.19", "Test::Code::TidyAll" : "0.50", "Test::EOL" : "0", "Test::Kwalitee" : "1.21", "Test::More" : "0.96", "Test::NoTabs" : "0", "Test::Pod" : "1.41", "Test::TrailingSpace" : "0.0203" } }, "runtime" : { "requires" : { "Data::Dumper" : "0", "File::Temp" : "0", "Getopt::Long" : "2.36", "IO::Select" : "0", "Term::ReadKey" : "0", "Term::ReadLine" : "0", "Text::Autoformat" : "0", "perl" : "5.014", "strict" : "0", "warnings" : "0" } }, "test" : { "requires" : { "File::Spec" : "0", "IO::Handle" : "0", "IPC::Open3" : "0", "Test::More" : "0.88", "base" : "0" } } }, "provides" : { "Term::Shell" : { "file" : "lib/Term/Shell.pm", "version" : "0.13" }, "Term::Shell::OnScopeLeave" : { "file" : "lib/Term/Shell.pm", "version" : "0.13" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "mailto" : "bug-term-shell@rt.cpan.org", "web" : "http://rt.cpan.org/NoAuth/Bugs.html?Dist=Term-Shell" }, "homepage" : "http://metacpan.org/release/Term-Shell", "repository" : { "type" : "git", "url" : "git://git@github.com:shlomif/Term-Shell.git", "web" : "https://github.com/shlomif/Term-Shell" } }, "version" : "0.13", "x_Dist_Zilla" : { "perl" : { "version" : "5.032001" }, "plugins" : [ { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "test", "type" : "requires" } }, "name" : "@Filter/TestMoreDoneTesting", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::ExecDir", "name" : "@Filter/ExecDir", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::GatherDir", "config" : { "Dist::Zilla::Plugin::GatherDir" : { "exclude_filename" : [], "exclude_match" : [], "follow_symlinks" : 0, "include_dotfiles" : 0, "prefix" : "", "prune_directory" : [], "root" : "." } }, "name" : "@Filter/GatherDir", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::ManifestSkip", "name" : "@Filter/ManifestSkip", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::MetaYAML", "name" : "@Filter/MetaYAML", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::PruneCruft", "name" : "@Filter/PruneCruft", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::Readme", "name" : "@Filter/Readme", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::RunExtraTests", "config" : { "Dist::Zilla::Role::TestRunner" : { "default_jobs" : 1 } }, "name" : "@Filter/RunExtraTests", "version" : "0.029" }, { "class" : "Dist::Zilla::Plugin::ShareDir", "name" : "@Filter/ShareDir", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::CheckChangesHasContent", "name" : "@Filter/CheckChangesHasContent", "version" : "0.011" }, { "class" : "Dist::Zilla::Plugin::ConfirmRelease", "name" : "@Filter/ConfirmRelease", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::Manifest", "name" : "@Filter/Manifest", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::MetaConfig", "name" : "@Filter/MetaConfig", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::MetaJSON", "name" : "@Filter/MetaJSON", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::MetaProvides::Package", "config" : { "Dist::Zilla::Plugin::MetaProvides::Package" : { "finder_objects" : [ { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : "@Filter/MetaProvides::Package/AUTOVIV/:InstallModulesPM", "version" : "6.024" } ], "include_underscores" : 0 }, "Dist::Zilla::Role::MetaProvider::Provider" : { "$Dist::Zilla::Role::MetaProvider::Provider::VERSION" : "2.002004", "inherit_missing" : 1, "inherit_version" : 1, "meta_noindex" : 1 }, "Dist::Zilla::Role::ModuleMetadata" : { "Module::Metadata" : "1.000037", "version" : "0.006" } }, "name" : "@Filter/MetaProvides::Package", "version" : "2.004003" }, { "class" : "Dist::Zilla::Plugin::MetaResources", "name" : "@Filter/MetaResources", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::ModuleBuild", "config" : { "Dist::Zilla::Role::TestRunner" : { "default_jobs" : 1 } }, "name" : "@Filter/ModuleBuild", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::PkgVersion", "name" : "@Filter/PkgVersion", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::PodSyntaxTests", "name" : "@Filter/PodSyntaxTests", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::Test::Compile", "config" : { "Dist::Zilla::Plugin::Test::Compile" : { "bail_out_on_fail" : 0, "fail_on_warning" : "author", "fake_home" : 0, "filename" : "t/00-compile.t", "module_finder" : [ ":InstallModules" ], "needs_display" : 0, "phase" : "test", "script_finder" : [ ":PerlExecFiles" ], "skips" : [], "switch" : [] } }, "name" : "@Filter/Test::Compile", "version" : "2.058" }, { "class" : "Dist::Zilla::Plugin::Test::CPAN::Changes", "config" : { "Dist::Zilla::Plugin::Test::CPAN::Changes" : { "changelog" : "Changes" } }, "name" : "@Filter/Test::CPAN::Changes", "version" : "0.012" }, { "class" : "Dist::Zilla::Plugin::Test::EOL", "config" : { "Dist::Zilla::Plugin::Test::EOL" : { "filename" : "xt/author/eol.t", "finder" : [ ":ExecFiles", ":InstallModules", ":TestFiles" ], "trailing_whitespace" : 1 } }, "name" : "@Filter/Test::EOL", "version" : "0.19" }, { "class" : "Dist::Zilla::Plugin::Test::NoTabs", "config" : { "Dist::Zilla::Plugin::Test::NoTabs" : { "filename" : "xt/author/no-tabs.t", "finder" : [ ":InstallModules", ":ExecFiles", ":TestFiles" ] } }, "name" : "@Filter/Test::NoTabs", "version" : "0.15" }, { "class" : "Dist::Zilla::Plugin::Test::TrailingSpace", "name" : "@Filter/Test::TrailingSpace", "version" : null }, { "class" : "Dist::Zilla::Plugin::TestRelease", "name" : "@Filter/TestRelease", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::PodWeaver", "config" : { "Dist::Zilla::Plugin::PodWeaver" : { "finder" : [ ":InstallModules", ":ExecFiles" ], "plugins" : [ { "class" : "Pod::Weaver::Plugin::SingleEncoding", "name" : "@SHLOMIF/SingleEncoding", "version" : "4.018" }, { "class" : "Pod::Weaver::Plugin::WikiDoc", "name" : "@SHLOMIF/WikiDoc", "version" : "0.093004" }, { "class" : "Pod::Weaver::Plugin::EnsurePod5", "name" : "@CorePrep/EnsurePod5", "version" : "4.018" }, { "class" : "Pod::Weaver::Plugin::H1Nester", "name" : "@CorePrep/H1Nester", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@SHLOMIF/Name", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Version", "name" : "@SHLOMIF/Version", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@SHLOMIF/Prelude", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@SHLOMIF/Synopsis", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@SHLOMIF/Description", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@SHLOMIF/Usage", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@SHLOMIF/Overview", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@SHLOMIF/Stability", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "Requirements", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "Attributes", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "Constructors", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "Methods", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "Functions", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Leftovers", "name" : "@SHLOMIF/Leftovers", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@SHLOMIF/postlude", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Support", "name" : "@SHLOMIF/Support", "version" : "1.013" }, { "class" : "Pod::Weaver::Section::Authors", "name" : "@SHLOMIF/Authors", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Bugs", "name" : "@SHLOMIF/Bugs", "version" : "4.018" }, { "class" : "Pod::Weaver::Section::Contributors", "name" : "@SHLOMIF/Contributors", "version" : "0.009" }, { "class" : "Pod::Weaver::Section::Legal", "name" : "@SHLOMIF/Legal", "version" : "4.018" }, { "class" : "Pod::Weaver::Plugin::Transformer", "name" : "@SHLOMIF/List", "version" : "4.018" } ] } }, "name" : "@Filter/PodWeaver", "version" : "4.009" }, { "class" : "Dist::Zilla::Plugin::UploadToCPAN", "name" : "@Filter/UploadToCPAN", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::AutoPrereqs", "name" : "AutoPrereqs", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::Keywords", "config" : { "Dist::Zilla::Plugin::Keywords" : { "keywords" : [ "console", "readline", "shell", "term", "terminal" ] } }, "name" : "Keywords", "version" : "0.007" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "runtime", "type" : "requires" } }, "name" : "Runtime", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::Test::Kwalitee", "config" : { "Dist::Zilla::Plugin::Test::Kwalitee" : { "filename" : "xt/release/kwalitee.t", "skiptest" : [] } }, "name" : "Test::Kwalitee", "version" : "2.12" }, { "class" : "Dist::Zilla::Plugin::Test::TidyAll", "name" : "Test::TidyAll", "version" : "0.04" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":InstallModules", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":IncModules", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":TestFiles", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExtraTestFiles", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExecFiles", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":PerlExecFiles", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ShareFiles", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":MainModule", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":AllFiles", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":NoFiles", "version" : "6.024" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : "@Filter/MetaProvides::Package/AUTOVIV/:InstallModulesPM", "version" : "6.024" } ], "zilla" : { "class" : "Dist::Zilla::Dist::Builder", "config" : { "is_trial" : 0 }, "version" : "6.024" } }, "x_generated_by_perl" : "v5.32.1", "x_serialization_backend" : "Cpanel::JSON::XS version 4.25", "x_spdx_expression" : "Artistic-1.0-Perl OR GPL-1.0-or-later" } weaver.ini100644000764000764 1314134244454 15720 0ustar00shlomifshlomif000000000000Term-Shell-0.13[@SHLOMIF] MANIFEST.SKIP100644000764000764 314134244454 15603 0ustar00shlomifshlomif000000000000Term-Shell-0.13~$ t000755000764000764 014134244454 14077 5ustar00shlomifshlomif000000000000Term-Shell-0.1301require.t100644000764000764 25014134244454 16216 0ustar00shlomifshlomif000000000000Term-Shell-0.13/tuse strict; use warnings; use Test::More tests => 1; use Term::Shell; my $shell = Term::Shell->new; # TEST ok( $shell, "A Term::Shell instance was initialised." ); 02default.t100644000764000764 253614134244454 16220 0ustar00shlomifshlomif000000000000Term-Shell-0.13/tpackage main; use strict; use warnings; use Test::More tests => 6; package MyShell; use base qw(Term::Shell); sub run_command1 { print "command1\n"; } sub smry_command1 { "what does command1 do?" } sub help_command1 { <<'END'; Help on 'command1', whatever that may be... END } sub run_command2 { print "command2\n"; } package main; my $shell = MyShell->new; #============================================================================= # Command completions #============================================================================= my $cmds = [ $shell->possible_actions( 'e', 'run' ) ]; # TEST is_deeply( $cmds, ['exit'], "e command" ); $cmds = [ $shell->possible_actions( 'h', 'run' ) ]; # TEST is_deeply( $cmds, ['help'], "help command" ); $cmds = [ $shell->possible_actions( 'c', 'run' ) ]; # TEST is( scalar(@$cmds), 2, "c run" ); #============================================================================= # Help completions #============================================================================= $cmds = [ $shell->possible_actions( 'e', 'help' ) ]; # TEST is_deeply( $cmds, ['exit'], "e completions" ); $cmds = [ $shell->possible_actions( 'h', 'help' ) ]; # TEST is_deeply( $cmds, ['help'], 'h completions' ); $cmds = [ $shell->possible_actions( 'c', 'help' ) ]; # TEST is_deeply( $cmds, ['command1'], 'command1 completions' ); 00-compile.t100644000764000764 263314134244454 16275 0ustar00shlomifshlomif000000000000Term-Shell-0.13/tuse 5.006; use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.058 use Test::More; plan tests => 1 + ($ENV{AUTHOR_TESTING} ? 1 : 0); my @module_files = ( 'Term/Shell.pm' ); # no fake home requested my @switches = ( -d 'blib' ? '-Mblib' : '-Ilib', ); use File::Spec; use IPC::Open3; use IO::Handle; open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; my @warnings; for my $lib (@module_files) { # see L my $stderr = IO::Handle->new; diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} } $^X, @switches, '-e', "require q[$lib]")) if $ENV{PERL_COMPILE_TEST_DEBUG}; my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-e', "require q[$lib]"); binmode $stderr, ':crlf' if $^O eq 'MSWin32'; my @_warnings = <$stderr>; waitpid($pid, 0); is($?, 0, "$lib loaded ok"); shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/ and not eval { +require blib; blib->VERSION('1.01') }; if (@_warnings) { warn @_warnings; push @warnings, @_warnings; } } is(scalar(@warnings), 0, 'no warnings found') or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ) if $ENV{AUTHOR_TESTING}; examples000755000764000764 014134244454 15452 5ustar00shlomifshlomif000000000000Term-Shell-0.13psh.pl100644000764000764 1153614134244454 16767 0ustar00shlomifshlomif000000000000Term-Shell-0.13/examples#!/usr/bin/perl -w use strict; my $obj = PSH->new; $obj->cmdloop; package PSH; use base qw(Term::Shell); use Data::Dumper; use Cwd; sub precmd { my $o = shift; my $hnd = shift; my $cmd = shift; my $args = shift; @$args = expand(@$args); } sub expand { for (@_) { $_ =~ s[^~][$ENV{HOME}]; $_ =~ s[\$([_A-Za-z0-9]+)][$ENV{$1} || '']eg; } @_; } sub prompt_str { my $cwd = cwd; $cwd =~ s[^\Q$ENV{HOME}\E][~]; "psh:$cwd> "; } sub smry_eval { "how to evaluate Perl code" } sub help_eval { <<'END'; You can evaluate snippets of Perl code just by putting them on a line beginning with !: psh:~> ! print "$_\n" for keys %ENV END } #============================================================================= # External commands #============================================================================= { my $eval_num = "000001"; sub catch_run { my ( $o, $command, @args ) = @_; # Evaluate perl code if it's a ! line. if ( $command =~ s/^!// ) { ( my $code = $o->line ) =~ s/^!//; my $really_long_string = <completions( $word, [ keys %ENV ] ); } my @files = glob("$word*"); return $o->completions( $word, \@files ); } sub comp_ { my ( $o, $word, $line, $start ) = @_; my @exes; use Config; for my $part ( split /\Q$Config{path_sep}\E/, $ENV{PATH} ) { next unless -d $part; opendir( PART, $part ) or die "can't opendir $part: $!"; while ( my $entry = readdir(PART) ) { my $file = "$part/$entry"; push @exes, $entry if -f $file and -x $file; } closedir(PART) or die "can't closedir $part: $!"; } my @comp = grep { length($_) } $o->possible_actions( $word, 'run', 1 ); push @comp, $o->completions( $word, \@exes ); @comp = sort @comp; @comp; } #============================================================================= # Shell Builtins #============================================================================= sub smry_echo { 'output the args' } sub help_echo { <<'END'; echo: echo [arg ...] Output the args. END } sub run_echo { my ( $o, @args ) = @_; my @exp = expand(@args); defined $_ or $_ = '' for @exp; print "@exp\n" if @exp; } sub smry_set { 'set environment variables' } sub help_set { <<'END'; set: set [ name[=value] ... ] set lets you manipulate environment variables. You can view environment variables using 'set'. To view specific variables, use 'set name'. To set environment variables, use 'set foo=bar'. END } sub run_set { my ( $o, @args ) = @_; if (@args) { for my $arg (@args) { my ( $key, $val ) = split /=/, $arg; if ( defined $val ) { $ENV{$key} = $val; } else { $val = $ENV{$key} || ''; print "$key=$val\n"; } } } else { my ( $key, $val ); while ( ( $key, $val ) = each %ENV ) { print "$key=$val\n"; } } } sub smry_cd { 'change working directory' } sub help_cd { <<'END'; cd: cd [dir] Change the current directory to DIR. The variable $HOME is the default DIR. END } sub run_cd { my ( $o, $dir ) = @_; $dir = $ENV{HOME} unless defined $dir; chdir $dir or do { print "$0: $dir: $!\n"; return; }; $ENV{PWD} = $dir; } __END__ # Not working yet... sub smry_alias { 'view or set command aliases' } sub help_alias { <<'END'; alias: [ name[=value] ... ] 'alias' with no arguments prints the list of aliases in the form NAME=VALUE on standard output. An alias is defined for each NAME whose VALUE is given. END } sub run_alias { my $o = shift; if (@_) { for my $a (@_) { my ($key, $val) = split /=/, $a; if (defined $val) { $o->{SHELL}{alias}{$key} = $val; } else { $val = $o->{SHELL}{alias}{$key}; print "alias $key=$val\n" if defined $val; print "alias: `$key' not found\n" if not defined $val; } } } else { my ($key, $val); while (($key, $val) = each %{$o->{SHELL}{alias}}) { print "alias $key=$val\n"; } } } 03catchsmry.t100644000764000764 235314134244454 16567 0ustar00shlomifshlomif000000000000Term-Shell-0.13/tpackage main; use strict; use warnings; use Test::More; if ( $^O eq 'MSWin32' ) { plan skip_all => "Test gets stuck on Windows - RT #40771"; } else { plan tests => 1; } require Term::Shell; { package Term::Shell::Test; use base 'Term::Shell'; sub summary { my $self = shift; $::called = 1; $self->SUPER::summary(@_); } sub run_fuzz { } }; my $sh = Term::Shell::Test->new; { $sh->run_help; }; # TEST unless ( is( $::called, 1, "catch_smry gets called for unknown methods" ) ) { diag "Term::Shell did not call a custom catch_smry handler"; diag "This is most likely because your version of Term::Shell"; diag "has a bug. Please upgrade to v0.02 or higher, which"; diag "should close this bug."; diag "If that is no option, patch sub help() in Term/Shell.pm, line 641ff."; diag "to:"; diag ' #my $smry = exists $o->{handlers}{$h}{smry};'; diag ' #? $o->summary($h);'; diag ' #: "undocumented";'; diag ' my $smry = $o->summary($h);'; diag 'Fixing this is not necessary - you will get no online help'; diag 'but the shell will otherwise work fine. Help is still'; diag 'available through ``perldoc WWW::Mechanize::Shell``'; } author000755000764000764 014134244454 15571 5ustar00shlomifshlomif000000000000Term-Shell-0.13/xteol.t100644000764000764 52114134244454 16653 0ustar00shlomifshlomif000000000000Term-Shell-0.13/xt/authoruse strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::EOL 0.19 use Test::More 0.88; use Test::EOL; my @files = ( 'lib/Term/Shell.pm', 't/00-compile.t', 't/01require.t', 't/02default.t', 't/03catchsmry.t' ); eol_unix_ok($_, { trailing_whitespace => 1 }) foreach @files; done_testing; Term000755000764000764 014134244454 15311 5ustar00shlomifshlomif000000000000Term-Shell-0.13/libShell.pm100644000764000764 15363414134244454 17132 0ustar00shlomifshlomif000000000000Term-Shell-0.13/lib/Termpackage Term::Shell; $Term::Shell::VERSION = '0.13'; use strict; use warnings; use 5.014; use Data::Dumper; use Term::ReadLine (); #============================================================================= # Term::Shell API methods #============================================================================= sub new { my $cls = shift; my $o = bless { term => eval { # Term::ReadKey throws ugliness all over the place if we're not # running in a terminal, which we aren't during "make test", at # least on FreeBSD. Suppress warnings here. local $SIG{__WARN__} = sub { }; Term::ReadLine->new('shell'); } || undef, }, ref($cls) || $cls; # Set up the API hash: $o->{command} = {}; $o->{API} = { args => \@_, case_ignore => ( $^O eq 'MSWin32' ? 1 : 0 ), check_idle => 0, # changing this isn't supported class => $cls, command => $o->{command}, cmd => $o->{command}, # shorthand match_uniq => 1, pager => $ENV{PAGER} || 'internal', readline => eval { $o->{term}->ReadLine } || 'none', script => ( caller(0) )[1], version => $Term::Shell::VERSION, }; # Note: the rl_completion_function doesn't pass an object as the first # argument, so we have to use a closure. This has the unfortunate effect # of preventing two instances of Term::ReadLine from coexisting. my $completion_handler = sub { $o->rl_complete(@_); }; if ( $o->{API}{readline} eq 'Term::ReadLine::Gnu' ) { my $attribs = $o->{term}->Attribs; $attribs->{completion_function} = $completion_handler; } elsif ( $o->{API}{readline} eq 'Term::ReadLine::Perl' ) { $readline::rl_completion_function = $readline::rl_completion_function = $completion_handler; } $o->find_handlers; $o->init; $o; } sub DESTROY { my $o = shift; $o->fini; } sub cmd { my $o = shift; $o->{line} = shift; if ( $o->line =~ /\S/ ) { my ( $cmd, @args ) = $o->line_parsed; $o->run( $cmd, @args ); unless ( $o->{command}{run}{found} ) { my @c = sort $o->possible_actions( $cmd, 'run' ); if ( @c and $o->{API}{match_uniq} ) { print $o->msg_ambiguous_cmd( $cmd, @c ); } else { print $o->msg_unknown_cmd($cmd); } } } else { $o->run(''); } } sub stoploop { $_[0]->{stop}++ } sub cmdloop { my $o = shift; $o->{stop} = 0; $o->preloop; while ( defined( my $line = $o->readline( $o->prompt_str ) ) ) { $o->cmd($line); last if $o->{stop}; } $o->postloop; } *mainloop = \&cmdloop; sub readline { my $o = shift; my $prompt = shift; return $o->{term}->readline($prompt) if $o->{API}{check_idle} == 0 or not defined $o->{term}->IN; # They've asked for idle-time running of some user command. local $Term::ReadLine::toloop = 1; local *Tk::fileevent = sub { my $cls = shift; my ( $file, $boring, $callback ) = @_; $o->{fh} = $file; # save the filehandle! $o->{cb} = $callback; # save the callback! }; local *Tk::DoOneEvent = sub { # We'll totally cheat and do a select() here -- the timeout will be # $o->{API}{check_idle}; if the handle is ready, we'll call &$cb; # otherwise we'll call $o->idle(), which can do some processing. my $timeout = $o->{API}{check_idle}; use IO::Select; if ( IO::Select->new( $o->{fh} )->can_read($timeout) ) { # Input is ready: stop the event loop. $o->{cb}->(); } else { $o->idle; } }; $o->{term}->readline($prompt); } sub term { $_[0]->{term} } # These are likely candidates for overriding in subclasses sub init { } # called last in the ctor sub fini { } # called first in the dtor sub preloop { } sub postloop { } sub precmd { } sub postcmd { } sub prompt_str { 'shell> ' } sub idle { } sub cmd_prefix { '' } sub cmd_suffix { '' } #============================================================================= # The pager #============================================================================= sub page { my $o = shift; my $text = shift; my $maxlines = shift || $o->termsize->{rows}; my $pager = $o->{API}{pager}; # First, count the number of lines in the text: my $lines = ( $text =~ tr/\n// ); # If there are fewer lines than the page-lines, just print it. if ( $lines < $maxlines or $maxlines == 0 or $pager eq 'none' ) { print $text; } # If there are more, page it, either using the external pager... elsif ( $pager and $pager ne 'internal' ) { require File::Temp; my ( $handle, $name ) = File::Temp::tempfile(); select( ( select($handle), $| = 1 )[0] ); print $handle $text; close $handle; system( $pager, $name ) == 0 or print < 0 ) { my @text = @lines[ $line .. $#lines ]; my $ret = $o->page_internal( \@text, $maxlines, $togo, $line ); last if $ret == -1; $line += $ret; $togo -= $ret; } return $line; } return $lines; } sub page_internal { my $o = shift; my $lines = shift; my $maxlines = shift; my $togo = shift; my $start = shift; my $line = 1; while ( $_ = shift @$lines ) { print; last if $line >= ( $maxlines - 1 ); # leave room for the prompt $line++; } my $lines_left = $togo - $line; my $current_line = $start + $line; my $total_lines = $togo + $start; my $instructions; if ( $o->have_readkey ) { $instructions = "any key for more, or q to quit"; } else { $instructions = "enter for more, or q to quit"; } if ( $lines_left > 0 ) { local $| = 1; my $l = "---line $current_line/$total_lines ($instructions)---"; my $b = ' ' x length($l); print $l; my $ans = $o->readkey; print "\r$b\r" if $o->have_readkey; print "\n" if $ans =~ /q/i or not $o->have_readkey; $line = -1 if $ans =~ /q/i; } $line; } #============================================================================= # Run actions #============================================================================= sub run { my $o = shift; my $action = shift; my @args = @_; $o->do_action( $action, \@args, 'run' ); } sub complete { my $o = shift; my $action = shift; my @args = @_; my @compls = $o->do_action( $action, \@args, 'comp' ); return () unless $o->{command}{comp}{found}; return @compls; } sub help { my $o = shift; my $topic = shift; my @subtopics = @_; $o->do_action( $topic, \@subtopics, 'help' ); } sub summary { my $o = shift; my $topic = shift; $o->do_action( $topic, [], 'smry' ); } #============================================================================= # Manually add & remove handlers #============================================================================= sub add_handlers { my $o = shift; my $match = sub { if ( my ($ret) = shift =~ /\A(run|help|smry|comp|catch|alias)_/ ) { return $ret; } return; }; LOOP1: for my $hnd (@_) { my $t = $match->($hnd); next LOOP1 if !defined $t; my $s = substr( $hnd, length($t) + 1 ); # Add on the prefix and suffix if the command is defined if ( length $s ) { substr( $s, 0, 0 ) = $o->cmd_prefix; $s .= $o->cmd_suffix; } $o->{handlers}{$s}{$t} = $hnd; } LOOP2: for my $hnd (@_) { my $t = $match->($hnd); next LOOP2 if !defined $t; my $s = substr( $hnd, length($t) + 1 ); # Add on the prefix and suffix if the command is defined if ( length $s ) { substr( $s, 0, 0 ) = $o->cmd_prefix; $s .= $o->cmd_suffix; } if ( $o->has_aliases($s) ) { my @s = $o->get_aliases($s); for my $alias (@s) { substr( $alias, 0, 0 ) = $o->cmd_prefix; $alias .= $o->cmd_suffix; $o->{handlers}{$alias}{$t} = $hnd; } } } } sub add_commands { my $o = shift; while (@_) { my ( $cmd, $hnd ) = ( shift, shift ); $o->{handlers}{$cmd} = $hnd; } } sub remove_handlers { my $o = shift; for my $hnd (@_) { next unless $hnd =~ /^(run|help|smry|comp|catch|alias)_/o; my $t = $1; my $a = substr( $hnd, length($t) + 1 ); # Add on the prefix and suffix if the command is defined if ( length $a ) { substr( $a, 0, 0 ) = $o->cmd_prefix; $a .= $o->cmd_suffix; } delete $o->{handlers}{$a}{$t}; } } sub remove_commands { my $o = shift; for my $name (@_) { delete $o->{handlers}{$name}; } } *add_handler = \&add_handlers; *add_command = \&add_commands; *remove_handler = \&remove_handlers; *remove_command = \&remove_commands; #============================================================================= # Utility methods #============================================================================= sub termsize { my $o = shift; my ( $rows, $cols ) = ( 24, 78 ); # Try several ways to get the terminal size TERMSIZE: { my $TERM = $o->{term}; last TERMSIZE unless $TERM; my $OUT = $TERM->OUT; if ( $TERM and $o->{API}{readline} eq 'Term::ReadLine::Gnu' ) { ( $rows, $cols ) = $TERM->get_screen_size; last TERMSIZE; } if ( $^O eq 'MSWin32' and eval { require Win32::Console } ) { Win32::Console->import; # Win32::Console's DESTROY does a CloseHandle(), so save the object: $o->{win32_stdout} ||= Win32::Console->new( STD_OUTPUT_HANDLE() ); my @info = $o->{win32_stdout}->Info; $cols = $info[7] - $info[5] + 1; # right - left + 1 $rows = $info[8] - $info[6] + 1; # bottom - top + 1 last TERMSIZE; } if ( eval { require Term::Size } ) { my @x = Term::Size::chars($OUT); if ( @x == 2 and $x[0] ) { ( $cols, $rows ) = @x; last TERMSIZE; } } if ( eval { require Term::Screen } ) { my $screen = Term::Screen->new; ( $rows, $cols ) = @$screen{qw(ROWS COLS)}; last TERMSIZE; } if ( eval { require Term::ReadKey } ) { ( $cols, $rows ) = eval { local $SIG{__WARN__} = sub { }; Term::ReadKey::GetTerminalSize($OUT); }; last TERMSIZE unless $@; } if ( $ENV{LINES} or $ENV{ROWS} or $ENV{COLUMNS} ) { $rows = $ENV{LINES} || $ENV{ROWS} || $rows; $cols = $ENV{COLUMNS} || $cols; last TERMSIZE; } { local $^W; if ( open( my $STTY, "-|", "stty", "size" ) ) { my $l = <$STTY>; ( $rows, $cols ) = split /\s+/, $l; close $STTY; } } } return { rows => $rows, cols => $cols }; } sub readkey { my $o = shift; $o->have_readkey unless $o->{readkey}; $o->{readkey}->(); } sub have_readkey { my $o = shift; return 1 if $o->{have_readkey}; my $IN = $o->{term}->IN; if ( eval { require Term::InKey } ) { $o->{readkey} = \&Term::InKey::ReadKey; } elsif ( $^O eq 'MSWin32' and eval { require Win32::Console } ) { $o->{readkey} = sub { my $c; # from Term::InKey: eval { # Win32::Console's DESTROY does a CloseHandle(), so save it: Win32::Console->import; $o->{win32_stdin} ||= Win32::Console->new( STD_INPUT_HANDLE() ); my $mode = my $orig = $o->{win32_stdin}->Mode or die $^E; $mode &= ~( ENABLE_LINE_INPUT() | ENABLE_ECHO_INPUT() ); $o->{win32_stdin}->Mode($mode) or die $^E; $o->{win32_stdin}->Flush or die $^E; $c = $o->{win32_stdin}->InputChar(1); die $^E unless defined $c; $o->{win32_stdin}->Mode($orig) or die $^E; }; die "Not implemented on $^O: $@" if $@; $c; }; } elsif ( eval { require Term::ReadKey } ) { $o->{readkey} = sub { Term::ReadKey::ReadMode( 4, $IN ); my $c = getc($IN); Term::ReadKey::ReadMode( 0, $IN ); $c; }; } else { $o->{readkey} = sub { scalar <$IN> }; return $o->{have_readkey} = 0; } return $o->{have_readkey} = 1; } *has_readkey = \&have_readkey; sub prompt { my $o = shift; my ( $prompt, $default, $completions, $casei ) = @_; my $term = $o->{term}; # A closure to read the line. my $line; my $readline = sub { my ( $sh, $gh ) = @{ $term->Features }{qw(setHistory getHistory)}; my @history = $gh ? $term->GetHistory : (); $term->SetHistory() if $sh; $line = $o->readline($prompt); $line = $default if ( ( not defined $line or $line =~ /^\s*$/ ) and defined $default ); # Restore the history $term->SetHistory(@history) if $sh; $line; }; # A closure to complete the line. my $complete = sub { my ( $word, $line, $start ) = @_; return $o->completions( $word, $completions, $casei ); }; if ( $term and $term->ReadLine eq 'Term::ReadLine::Gnu' ) { my $attribs = $term->Attribs; local $attribs->{completion_function} = $complete; &$readline; } elsif ( $term and $term->ReadLine eq 'Term::ReadLine::Perl' ) { local $readline::rl_completion_function = $complete; &$readline; } else { &$readline; } $line; } sub format_pairs { my $o = shift; my @keys = @{ shift(@_) }; my @vals = @{ shift(@_) }; my $sep = shift || ": "; my $left = shift || 0; my $ind = shift || ""; my $len = shift || 0; my $wrap = shift || 0; if ($wrap) { eval { require Text::Autoformat; Text::Autoformat->import(qw(autoformat)); }; if ($@) { warn( "Term::Shell::format_pairs(): Text::Autoformat is required " . "for wrapping. Wrapping disabled" ) if $^W; $wrap = 0; } } my $cols = shift || $o->termsize->{cols}; $len < length($_) and $len = length($_) for @keys; my @text; for my $i ( 0 .. $#keys ) { next unless defined $vals[$i]; my $sz = ( $len - length( $keys[$i] ) ); my $lpad = $left ? "" : " " x $sz; my $rpad = $left ? " " x $sz : ""; my $l = "$ind$lpad$keys[$i]$rpad$sep"; my $wrap = $wrap & ( $vals[$i] =~ /\s/ and $vals[$i] !~ /^\d/ ); my $form = ( $wrap ? autoformat( "$vals[$i]", # force stringification { left => length($l) + 1, right => $cols, all => 1 }, ) : "$l$vals[$i]\n" ); substr( $form, 0, length($l), $l ); push @text, $form; } my $text = join '', @text; return wantarray ? ( $text, $len ) : $text; } sub print_pairs { my $o = shift; my ( $text, $len ) = $o->format_pairs(@_); $o->page($text); return $len; } # Handle backslash translation; doesn't do anything complicated yet. sub process_esc { my $o = shift; my $c = shift; my $q = shift; my $n; return '\\' if $c eq '\\'; return $q if $c eq $q; return "\\$c"; } # Parse a quoted string sub parse_quoted { my $o = shift; my $raw = shift; my $quote = shift; my $i = 1; my $string = ''; my $c; while ( $i <= length($raw) and ( $c = substr( $raw, $i, 1 ) ) ne $quote ) { if ( $c eq '\\' ) { $string .= $o->process_esc( substr( $raw, $i + 1, 1 ), $quote ); $i++; } else { $string .= substr( $raw, $i, 1 ); } $i++; } return ( $string, $i ); } sub line { my $o = shift; $o->{line}; } sub line_args { my $o = shift; my $line = shift || $o->line; $o->line_parsed($line); $o->{line_args} || ''; } sub line_parsed { my $o = shift; my $args = shift || $o->line || return (); my @args; # Parse an array of arguments. Whitespace separates, unless quoted. my $arg = undef; $o->{line_args} = undef; for ( my $i = 0 ; $i < length($args) ; $i++ ) { my $c = substr( $args, $i, 1 ); if ( $c =~ /\S/ and @args == 1 ) { $o->{line_args} ||= substr( $args, $i ); } if ( $c =~ /['"]/ ) { my ( $str, $n ) = $o->parse_quoted( substr( $args, $i ), $c ); $i += $n; $arg = ( defined($arg) ? $arg : '' ) . $str; } # We do not parse outside of strings # elsif ($c eq '\\') { # $arg = (defined($arg) ? $arg : '') # . $o->process_esc(substr($args,$i+1,1)); # $i++; # } elsif ( $c =~ /\s/ ) { push @args, $arg if defined $arg; $arg = undef; } else { $arg .= substr( $args, $i, 1 ); } } push @args, $arg if defined($arg); return @args; } sub handler { my $o = shift; my ( $command, $type, $args, $preserve_args ) = @_; # First try finding the standard handler, then fallback to the # catch_$type method. The columns represent "action", "type", and "push", # which control whether the name of the command should be pushed onto the # args. my @tries = ( [ $command, $type, 0 ], [ $o->cmd_prefix . $type . $o->cmd_suffix, 'catch', 1 ], ); # The user can control whether or not to search for "unique" matches, # which means calling $o->possible_actions(). We always look for exact # matches. my @matches = qw(exact_action); push @matches, qw(possible_actions) if $o->{API}{match_uniq}; for my $try (@tries) { my ( $cmd, $type, $add_cmd_name ) = @$try; for my $match (@matches) { my @handlers = $o->$match( $cmd, $type ); next unless @handlers == 1; unshift @$args, $command if $add_cmd_name and not $preserve_args; return $o->unalias( $handlers[0], $type ); } } return; } sub completions { my $o = shift; my $action = shift; my $compls = shift || []; my $casei = shift; $casei = $o->{API}{case_ignore} unless defined $casei; $casei = $casei ? '(?i)' : ''; return grep { $_ =~ /$casei^\Q$action\E/ } @$compls; } #============================================================================= # Term::Shell error messages #============================================================================= sub msg_ambiguous_cmd { my ( $o, $cmd, @c ) = @_; local $" = "\n\t"; <handler( $cmd, $type, $args ); $o->{command}{$type} = { cmd => $cmd, name => $cmd, found => defined $handler ? 1 : 0, cmdfull => $fullname, cmdreal => $cmdname, handler => $handler, }; if ( defined $handler ) { # We've found a handler. Set up a value which will call the postcmd() # action as the subroutine leaves. Then call the precmd(), then return # the result of running the handler. $o->precmd( \$handler, \$cmd, $args ); my $postcmd = Term::Shell::OnScopeLeave->new( sub { $o->postcmd( \$handler, \$cmd, $args ); } ); return $o->$handler(@$args); } } sub uniq { my $o = shift; my %seen; $seen{$_}++ for @_; my @ret; for (@_) { push @ret, $_ if $seen{$_}-- == 1 } @ret; } sub possible_actions { my $o = shift; my $action = shift; my $type = shift; my $casei = $o->{API}{case_ignore} ? '(?i)' : ''; my @keys = grep { $_ =~ /$casei^\Q$action\E/ } grep { exists $o->{handlers}{$_}{$type} } keys %{ $o->{handlers} }; return @keys; } sub exact_action { my $o = shift; my $action = shift; my $type = shift; my $casei = $o->{API}{case_ignore} ? '(?i)' : ''; my @key = grep { $action =~ /$casei^\Q$_\E$/ } grep { exists $o->{handlers}{$_}{$type} } keys %{ $o->{handlers} }; return () unless @key == 1; return $key[0]; } sub is_alias { my $o = shift; my $action = shift; exists $o->{handlers}{$action}{alias} ? 1 : 0; } sub has_aliases { my $o = shift; my $action = shift; my @a = $o->get_aliases($action); @a ? 1 : 0; } sub get_aliases { my $o = shift; my $action = shift; my @a = eval { my $hndlr = $o->{handlers}{$action}{alias}; return () unless $hndlr; $o->$hndlr(); }; $o->{aliases}{$_} = $action for @a; @a; } sub unalias { my $o = shift; my $cmd = shift; # i.e 'foozle' my $type = shift; # i.e 'run' return () unless $type; return ( $cmd, $cmd, $o->{handlers}{$cmd}{$type} ) unless exists $o->{aliases}{$cmd}; my $alias = $o->{aliases}{$cmd}; # I'm allowing aliases to call handlers which have been removed. This # means I can set up an alias of '!' for 'shell', then delete the 'shell' # command, so that you can only access it through '!'. That's why I'm # checking the {handlers} entry _and_ building a string. my $handler = $o->{handlers}{$alias}{$type} || "${type}_${alias}"; return ( $cmd, $alias, $handler ); } sub find_handlers { my $o = shift; my $pkg = shift || $o->{API}{class}; # Find the handlers in the given namespace: my %handlers; { ## no critic no strict 'refs'; my @r = keys %{ $pkg . "::" }; $o->add_handlers(@r); } # Find handlers in its base classes. { ## no critic no strict 'refs'; my @isa = @{ $pkg . "::ISA" }; for my $pkg (@isa) { $o->find_handlers($pkg); } } } sub rl_complete { my $o = shift; my ( $word, $line, $start ) = @_; # If it's a command, complete 'run_': if ( $start == 0 or substr( $line, 0, $start ) =~ /^\s*$/ ) { my @compls = $o->complete( '', $word, $line, $start ); return @compls if $o->{command}{comp}{found}; } # If it's a subcommand, send it to any custom completion function for the # function: else { my $command = ( $o->line_parsed($line) )[0]; my @compls = $o->complete( $command, $word, $line, $start ); return @compls if $o->{command}{comp}{found}; } (); } #============================================================================= # Two action handlers provided by default: help and exit. #============================================================================= sub smry_exit { "exits the program" } sub help_exit { <<'END'; Exits the program. END } sub run_exit { my $o = shift; $o->stoploop; } sub smry_help { "prints this screen, or help on 'command'" } sub help_help { <<'END'; Provides help on commands... END } sub comp_help { my ( $o, $word, $line, $start ) = @_; my @words = $o->line_parsed($line); return [] if ( @words > 2 or @words == 2 and $start == length($line) ); sort $o->possible_actions( $word, 'help' ); } sub run_help { my $o = shift; my $cmd = shift; if ($cmd) { my $txt = $o->help( $cmd, @_ ); if ( $o->{command}{help}{found} ) { $o->page($txt); } else { my @c = sort $o->possible_actions( $cmd, 'help' ); if ( @c and $o->{API}{match_uniq} ) { local $" = "\n\t"; print <{handlers} } ) { next unless length($h); next unless grep { defined $o->{handlers}{$h}{$_} } qw(run smry help); my $dest = exists $o->{handlers}{$h}{run} ? \%cmds : \%docs; my $smry = do { my $x = $o->summary($h); $x ? $x : "undocumented" }; my $help = exists $o->{handlers}{$h}{help} ? ( exists $o->{handlers}{$h}{smry} ? "" : " - but help available" ) : " - no help available"; $dest->{" $h"} = "$smry$help"; } my @t; push @t, " Commands:\n" if %cmds; push @t, scalar $o->format_pairs( [ sort keys %cmds ], [ map { $cmds{$_} } sort keys %cmds ], ' - ', 1 ); push @t, " Extra Help Topics: (not commands)\n" if %docs; push @t, scalar $o->format_pairs( [ sort keys %docs ], [ map { $docs{$_} } sort keys %docs ], ' - ', 1 ); $o->page( join '', @t ); } } sub run_ { } sub comp_ { my ( $o, $word, $line, $start ) = @_; my @comp = grep { length($_) } sort $o->possible_actions( $word, 'run' ); return @comp; } package Term::Shell::OnScopeLeave; $Term::Shell::OnScopeLeave::VERSION = '0.13'; sub new { return bless [ @_[ 1 .. $#_ ] ], ref( $_[0] ) || $_[0]; } sub DESTROY { my $o = shift; for my $c (@$o) { $c->(); } return; } 1; __END__ =pod =encoding utf-8 =head1 NAME Term::Shell - A simple command-line shell framework. =head1 VERSION version 0.13 =head1 SYNOPSIS package MyShell; use base qw(Term::Shell); sub run_command1 { print "command 1!\n"; } sub smry_command1 { "what does command1 do?" } sub help_command1 { <<'END'; Help on 'command1', whatever that may be... END } sub run_command2 { print "command 2!\n"; } package main; my $shell = MyShell->new; $shell->cmdloop; =head1 DESCRIPTION Term::Shell lets you write simple command-line shells. All the boring details like command-line parsing, terminal handling, and tab completion are handled for you. The base class comes with two commands pre-defined: exit and help. To write a shell with an C command, do something like this: package MyShell; use base qw(Term::Shell); # or manually edit @MyShell::ISA. sub run_exec { my ($o, $cmd, @args) = @_; if ($cmd ne $0) { print "I'm sorry you're leaving us...\n"; } exec $cmd, @args; exit 1; } When Term::Shell needs to handle the C command, it will invoke this method. That's all there is to it! You write handlers, and Term::Shell handles the gory details. =head1 Using Term::Shell Shells How do you bring your shell to life? Assuming the package C contains your actions, just do this: use MyShell; my $shell = MyShell->new; # Setup code here (if you wish) # Invoke the shell $shell->cmdloop; # Cleanup code here (if you wish) Most people put the setup code in the shell itself, so you can usually get away with this: use MyShell; MyShell->new->cmdloop; It's that simple! All the actions and command handlers go in C, and your main program is simple. In fact, it's so simple that some people like to write both the actions and the invocation in the same file: package main; MyShell->new->cmdloop; package MyShell; use base qw(Term::Shell); # Actions here Adding commands to your shell is just as easy, if not easier. =head1 Adding Commands to Your Shell For every command C, Term::Shell needs a method called C, where 'foo' is what the user will type in. The method will be called with the Term::Shell object as the first parameter, followed by any arguments the user typed after the command. Several prefixes other than C are supported; each prefix tells Term::Shell to call that handler under different circumstances. The following list enumerates all the "special" prefixes. Term::Shell will ignore any method that doesn't start with a prefix listed here. =over 4 =item 1 run_foo() Adds the command C to the list of supported commands. The method's return value is saved by Term::Shell, but is not used. The method is called with the Term::Shell object as its first argument, followed by any arguments the user typed in. Special case: if you provide a method C, Term::Shell will call it whenever the user enters a blank line. A blank line is anything which matches the regular expression C. =item 2 help_foo() Adds the command C to the list of help topics. This means the user may enter 'help foo' and get a help screen. It should return a single string to be displayed to the user. The method is called with the Term::Shell object as its first argument, followed by any arguments the user typed in after 'help foo'. You can implement hierarchical help documents by using the arguments. If you do not provide a C method, typing 'help foo' produces an error message. =item 3 smry_foo() Should return a one-line summary of C, to be displayed in the help screen. This method is called with the Term::Shell object as its first argument, and no other arguments. If you do not provide a C method, then the string 'undocumented' is used instead. =item 4 comp_foo() Provides custom tab-completion for C. That means if the user types 'foo ' and then hits , this method will be called. It should return an array reference containing a list of possible completions. This method is called with the Term::Shell object as its first argument, followed by the three arguments: =over 4 =item 1 $word The word the user is trying to complete. =item 2 $line The line as typed by the user so far. =item 3 $start The offset into $line where $word starts. =back If you do not provide C, Term::Shell will always return no completions for C. Special case: if you provide C, Term::Shell will call it when the user is trying to complete the name of a command. Term::Shell provides a default C method, which completes the actions that you have written handlers for. If you want to provide tab-completion for commands that do not have handlers, override C. =item 5 alias_foo() Returns a list of aliases for C. When one of the aliases is used instead of C, the corresponding handler for C is called. =item 6 catch_run() catch_help() catch_comp() catch_smry() Called when an undefined action is entered by the user. Normally when the user enters an unrecognized command, Term::Shell will print an error message and continue. This method is called with the Term::Shell object, the command typed by the user, and then the arguments which would normally be passed to the real handler. The C methods may do anything the original function would have done. If you want, you can implement all the commands in it, but that means you're doing more work than you have to. Be lazy. =back =head2 When you want something done right... You sometimes have to do it yourself. Introducing add_handlers(). Naturally, it adds a handler to the list of defined handlers in the shell. Term::Shell can't always find the commands you want to implement by searching the inheritance tree. Having an AUTOLOAD() method, for instance, will break this system. In that situation, you may wish to tell Term::Shell about the extra commands available using add_handlers(): package MyShell; use base qw(Term::Shell); sub AUTOLOAD { if ($AUTOLOAD =~ /::run_fuzz$/) { # code for 'fuzz' command } elsif ($AUTOLOAD =~ /::run_foozle$/) { # code for 'foozle' command } } sub init { my $o = shift; $o->add_handlers("run_fuzz", "run_foozle"); } There are other ways to do this. You could write a C routine and do the same thing from there. You'd have to override C so that it would complete on "foozle" and "fuzz". The advantage to this method is that it adds the methods to the list of commands, so they show up in the help menu I you get completion for free. =head1 Removing Commands from Your Shell You're probably thinking "just don't write them". But remember, you can inherit from another shell class, and that parent may define commands you want to disable. Term::Shell provides a simple method to make itself forget about commands it already knows about: =over 4 =item 1 remove_commands() Removes all handlers associated with the given command (or list of commands). For example, Term::Shell comes with two commands (C and C) implemented with seven handlers: =over 4 =item 1 smry_exit() =item 2 help_exit() =item 3 run_exit() =item 4 smry_help() =item 5 help_help() =item 6 comp_help() =item 7 run_help() =back If you want to create a shell that doesn't implement the C command, your code might look something like this example: package MyShell; use base qw(Term::Shell); sub init { my $o = shift; $o->remove_commands("help"); } # ... define more handlers here ... =item 2 remove_handlers() Removes the given handler (or handlers) from the list of defined commands. You have to specify a full handler name, including the 'run_' prefix. You can obviously specify any of the other prefixes too. If you wanted to remove the help for the C command, but preserve the command itself, your code might look something like this: package MyShell; use base qw(Term::Shell); sub init { my $o = shift; $o->remove_handlers("help_exit"); } # ... define more handlers here ... =back =head2 Cover Your Tracks If you do remove built in commands, you should be careful not to let Term::Shell print references to them. Messages like this are guaranteed to confuse people who use your shell: shell> help Unknown command 'help'; type 'help' for a list of commands. Here's the innocuous looking code: package MyShell; use base qw(Term::Shell); sub init { my $o = shift; $o->remove_commands("help"); } MyShell->new->cmdloop; The problem is that Term::Shell has to print an error message, and by default it tells the user to use the C command to see what's available. If you remove the C command, you still have to clean up after yourself and tell Term::Shell to change its error messages: =over 4 =item 1 msg_unknown_cmd() Called when the user has entered an unrecognized command, and no action was available to satisfy it. It receives the object and the command typed by the user as its arguments. It should return an error message; by default, it is defined thusly: sub msg_unknown_cmd { my ($o, $cmd) = @_; <{API}{args}', in case you want to use them later. my $sh = Term::Shell->new(@arbitrary_args); =item 2 cmd() cmd($txt); Invokes C<$txt> as if it had been typed in at the prompt. $sh->cmd("echo 1 2 3"); =item 3 cmdloop() mainloop() Repeatedly prompts the user, reads a line, parses it, and invokes a handler. Uses C internally. MyShell->new->cmdloop; mainloop() is a synonym for cmdloop(), provided for backwards compatibility. Earlier (unreleased) versions of Term::Shell have only provided mainloop(). All documentation and examples use cmdloop() instead. =item 4 init() fini() Do any initialization or cleanup you need at shell creation (init()) and destruction (fini()) by defining these methods. No parameters are passed. =item 5 preloop() postloop() Do any initialization or cleanup you need at shell startup (preloop()) and shutdown (postloop()) by defining these methods. No parameters are passed. =item 6 precmd() postcmd() Do any initialization or cleanup before and after calling each handler. The parameters are: =over 4 =item 1 $handler A reference to the name of the handler that is about to be executed. Passed by reference so you can control which handler will be called. =item 2 $cmd A reference to the command as the user typed it. Passed by reference so you can set the command. (If the handler is a "catch_" command, it can be fooled into thinking the user typed some other command, for example.) =item 3 $args The arguments as typed by the user. This is passed as an array reference so that you can manipulate the arguments received by the handler. =back sub precmd { my $o = shift; my ($handler, $cmd, @args) = @_; # ... } =item 7 stoploop() Sets a flag in the Term::Shell object that breaks out of cmdloop(). Note that cmdloop() resets this flag each time you call it, so code like this will work: my $sh = MyShell->new; $sh->cmdloop; # an interactive session $sh->cmdloop; # prompts the user again Term::Shell's built-in run_exit() command just calls stoploop(). =item 8 idle() If you set C to a non-zero number (see L) then this method is called every C seconds. The idle() method defined in Term::Shell does nothing -- it exists only to be redefined in subclasses. package MyShell; use base qw(Term::Shell); sub init { my $o = shift; $o->{API}{check_idle} = 0.1; # 10/s } sub idle { print "Idle!\n"; } =item 9 prompt_str() Returns a string to be used as the prompt. prompt_str() is called just before calling the readline() method of Term::ReadLine. If you do not override this method, the string `shell> ' is used. package MyShell; use base qw(Term::Shell); sub prompt_str { "search> " } =item 10 prompt() Term::Shell provides this method for convenience. It's common for a handler to ask the user for more information. This method makes it easy to provide the user with a different prompt and custom completions provided by you. The prompt() method takes the following parameters: =over 4 =item 1 $prompt The prompt to display to the user. This can be any string you want. =item 2 $default The default value to provide. If the user enters a blank line (all whitespace characters) then the this value will be returned. Note: unlike ExtUtils::MakeMaker's prompt(), Term::Shell's prompt() does not modify $prompt to indicate the $default response. You have to do that yourself. =item 3 $completions An optional list of completion values. When the user hits , Term::Shell prints the completions which match what they've typed so far. Term::Shell does not enforce that the user's response is one of these values. =item 4 $casei An optional boolean value which indicates whether the completions should be matched case-insensitively or not. A true value indicates that C and C should be considered the same. =back prompt() returns the unparsed line to give you maximum flexibility. If you need the line parsed, use the line_parsed() method on the return value. =item 11 cmd_prefix() cmd_suffix() These methods should return a prefix and suffix for commands, respectively. For instance, an IRC client will have a prefix of C. Most shells have an empty prefix and suffix. =item 12 page() page($txt) Prints C<$txt> through a pager, prompting the user to press a key for the next screen full of text. =item 13 line() line_parsed() Although C is called with the parsed arguments from the command-line, you may wish to see the raw command-line. This is available through the line() method. If you want to retrieve the parsed line again, use line_parsed(). line_parsed() accepts an optional string parameter: the line to parse. If you have your own line to parse, you can pass it to line_parsed() and get back a list of arguments. This is useful inside completion methods, since you don't get a parsed list there. =item 14 run() If you want to run another handler from within a handler, and you have pre-parsed arguments, use run() instead of cmd(). cmd() parses its parameter, whereas run() takes each element as a separate parameter. It needs the name of the action to run and any arguments to pass to the handler. Term::Shell uses this method internally to invoke command handlers. =item 15 help() If you want to get the raw text of a help message, use help(). It needs the name of the help topic and any arguments to pass to the handler. Term::Shell uses this method internally to invoke help handlers. =item 16 summary() If you want to get the summary text of an action, use summary(). It needs the name of the action. Term::Shell uses this method internally to display the help page. =item 17 possible_actions() You will probably want this method in comp_foo(). possible_actions() takes a word and a list, and returns a list of possible matches. Term::Shell uses this method internally to decide which handler to run when the user enters a command. There are several arguments, but you probably won't use them all in the simple cases: =over 4 =item 1 $needle The (possible incomplete) word to try to match against the list of actions (the haystack). =item 2 $type The type with which to prefix C<$action>. This is useful when completing a real action -- you have to specify whether you want it to look for "run_" or "help_" or something else. If you leave it blank, it will use C<$action> without prefixing it. =item 3 $strip If you pass in a true value here, possible_actions() will remove an initial C<$type> from the beginning of each result before returning the results. This is useful if you want to know what the possible "run_" commands are, but you don't want to have the "run_" in the final result. If you do not specify this argument, it uses '0' (the default is not to strip the results). =item 4 $haystack You can pass in a reference to a list of strings here. Each string will be compared with C<$needle>. If you do not specify this argument, it uses the list of handlers. This is how Term::Shell matches commands typed in by the user with command handlers written by you. =back =item 18 print_pairs() This overloaded beast is used whenever Term::Shell wants to print a set of keys and values. It handles wrapping long values, indenting the whole thing, inserting the separator between the key and value, and all the rest. There are lots of parameters, but most of them are optional: =over 4 =item 1 $keys A reference to a list of keys to print. =item 2 $values A reference to a list of values to print. =item 3 $sep The string used to separate the keys and values. If omitted, ': ' is used. =item 4 $left The justification to be used to line up the keys. If true, the keys will be left-justified. If false or omitted, the keys will be right-justified. =item 5 $ind A string used to indent the whole paragraph. Internally, print_pairs() uses length(), so you shouldn't use tabs in the indent string. If omitted, the empty string is used (no indent). =item 6 $len An integer which describes the minimum length of the keys. Normally, print_pairs() calculates the longest key and assigns the column width to be as wide as the longest key plus the separator. You can force the column width to be larger using $len. If omitted, 0 is used. =item 7 $wrap A boolean which indicates whether the value should be text-wrapped using Text::Autoformat. Text is only ever wrapped if it contains at least one space. If omitted, 0 is used. =item 8 $cols An integer describing the number of columns available on the current terminal. Normally 78 is used, or the environment variable COLUMNS, but you can override the number here to simulate a right-indent. =back =item 19 term() Returns the underlying C object used to interact with the user. You can do powerful things with this object; in particular, you will cripple Term::Shell's completion scheme if you change the completion callback function. =item 20 process_esc() This method may be overridden to provide shell-like escaping of backslashes inside quoted strings. It accepts two parameters: =over 4 =item 1 $c The character which was escaped by a backslash. =item 2 $quote The quote character used to delimit this string. Either C<"> or C<'>. =back This method should return the string which should replace the backslash and the escaped character. By default, process_esc() uses escaping rules similar to Perl's single-quoted string: =over 4 =item 1 Escaped backslashes return backslashes. The string C<"123\\456"> returns C<123\456>. =item 2 Escaped quote characters return the quote character (to allow quote characters in strings). The string C<"abc\"def"> returns C. =item 3 All other backslashes are returned verbatim. The string C<"123\456"> returns C<123\456>. =back Term::Shell's quote characters cannot be overridden, unless you override line_parsed(): they are C<"> or C<'>. This may change in a future version of Term::Shell. =item 21 add_handlers() See L for information on add_handlers(). =item 22 remove_commands() remove_handlers() See L for information on remove_handlers(). =back =head1 The Term::Shell Object Term::Shell creates a hash based Perl object. The object contains information like what handlers it found, the underlying Term::ReadLine object, and any arguments passed to the constructor. This hash is broken into several subhashes. The only two subhashes that a Shell should ever use are $o->{API} and $o->{SHELL}. The first one contains all the information that Term::Shell has gathered for you. The second one is a private area where your Shell can freely store data that it might need later on. This section will describe all the Term::Shell object "API" attributes: =head2 The args Attribute This an array reference containing any arguments passed to the Term::Shell constructor. =head2 The case_ignore Attribute This boolean controls whether commands should be matched without regard to case. If this is true, then typing C will have the same effect as typing C. Defaults to true on MSWin32, and false on other platforms. =head2 The class Attribute The class of the object. This is probably the package containing the definition of your shell, but if someone subclasses I shell, it's their class. =head2 The command Attribute Whenever Term::Shell invokes an action, it stores information about the action in the C attribute. Information about the last "run" action to be invoked is stored in $o->{API}{command}{run}. The information itself is stored in a subhash containing these fields: =over 4 =item name The name of the command, as typed by the user. =item found The a boolean value indicating whether a handler could be found. =item handler The full name of the handler, if found. =back Note that this facility only stores information about the I action to be executed. It's good enough for retrieving the information about the last handler which ran, but not for much else. The following example shows a case where C calls C, and prints its return value (in this case, 42). sub run_foo { my $o = shift; my $sum = $o->run("add", 21, 21); print "21 + 21 = ", $sum, "\n"; } sub run_add { my $o = shift; my $sum = 0; $sum += $_ for @_; print "add(): sum = $sum\n"; return $sum; } At the end of run_foo(), $o->{API}{command}{run}{handler} contains the string C<"run_add">. =head2 The match_uniq Attribute This boolean controls whether the user can type in only enough of the command to make it unambiguous. If true, then if the shell has the commands C and C defined, the user can type C to run C, and C to run C. Defaults to true. =head2 The readline Attribute Which Term::ReadLine module is being used. Currently, this is always one of C, C, or C. =head2 The script Attribute The name of the script that invoked your shell. =head2 The version Attribute The version of Term::Shell you are running under. =head1 SEE ALSO For more information about the underlying ReadLine module, see L. You may also want to look at L and L. For more information about the underlying formatter used by print_pairs(), see L. The API for Term::Shell was inspired by (gasp!) a Python package called C. For more information about this package, please look in the Python Library Reference, either in your Python distribution or at L . =head1 AUTHOR Neil Watkiss (NEILW@cpan.org) =head1 COPYRIGHT Copyright (c) 2001, Neil Watkiss. All Rights Reserved. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html =for :stopwords cpan testmatrix url bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan =head1 SUPPORT =head2 Websites The following websites have more information about this module, and may be of help to you. As always, in addition to those websites please use your favorite search engine to discover more resources. =over 4 =item * MetaCPAN A modern, open-source CPAN search engine, useful to view POD in HTML format. L =item * RT: CPAN's Bug Tracker The RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN. L =item * CPANTS The CPANTS is a website that analyzes the Kwalitee ( code metrics ) of a distribution. L =item * CPAN Testers The CPAN Testers is a network of smoke testers who run automated tests on uploaded CPAN distributions. L =item * CPAN Testers Matrix The CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms. L =item * CPAN Testers Dependencies The CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution. L =back =head2 Bugs / Feature Requests Please report any bugs or feature requests by email to C, or through the web interface at L. You will be automatically notified of any progress on the request by the system. =head2 Source Code The code is open to the world, and available for you to hack on. Please feel free to browse it and play with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull from your repository :) L git clone git://git@github.com:shlomif/Term-Shell.git =head1 AUTHOR Shlomi Fish =head1 BUGS Please report any bugs or feature requests on the bugtracker website L or by email to L. When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2001 by Neil Watkiss. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut no-tabs.t100644000764000764 46714134244454 17450 0ustar00shlomifshlomif000000000000Term-Shell-0.13/xt/authoruse strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::NoTabs 0.15 use Test::More 0.88; use Test::NoTabs; my @files = ( 'lib/Term/Shell.pm', 't/00-compile.t', 't/01require.t', 't/02default.t', 't/03catchsmry.t' ); notabs_ok($_) foreach @files; done_testing; tidyall.t100644000764000764 52214134244454 17537 0ustar00shlomifshlomif000000000000Term-Shell-0.13/xt/author# This file was automatically generated by Dist::Zilla::Plugin::Test::TidyAll v$VERSION use Test::More 0.88; use Test::Code::TidyAll 0.24; tidyall_ok( verbose => ( exists $ENV{TEST_TIDYALL_VERBOSE} ? $ENV{TEST_TIDYALL_VERBOSE} : 0 ), jobs => ( exists $ENV{TEST_TIDYALL_JOBS} ? $ENV{TEST_TIDYALL_JOBS} : 1 ), ); done_testing; old-test.pl100644000764000764 631314134244454 17705 0ustar00shlomifshlomif000000000000Term-Shell-0.13/examples#!perl -w package App; use strict; use base qw(Term::Shell); use Data::Dumper; sub init { my $o = shift; $o->remove_handlers("run_squiggle"); $o->{API}{match_uniq} = 0; # allow only exact matches $o->{API}{check_idle} = 1; # run on_idle() every 1 second } sub idle { my $o = shift; $o->{SHELL}{num}++; } # The default method (when you enter a blank line). This command is not shown # in the help or in completion lists. sub run_ { print "Default command...\n"; } # A standard command. It has a summary (smry_), help topic (help_), and an # action. But it doesn't provide custom command completion (comp_). sub smry_fuzz { "A test for bears at play" } sub help_fuzz { <<'END'; Fuzzy bears are harsh quacked, man. END } sub run_fuzz { my $o = shift; print "Please enter the name of your mother.\n"; my $l = $o->prompt( 'Name: ', undef, [qw(Jill Mary Blanche)] ); print "Say hi to $l for me!\n"; } # This command ('proxy') runs 'foo' and prints its return value (42). sub run_proxy { my $o = shift; my $c = shift; my $r = $o->run( $c || "foo", @_ ); print "Foo returned: ", $r, "\n"; print Dumper $o->{API}{command}; } sub catch_run { my $o = shift; my $cmd = shift; print "NOTE: catch_run() called. Emulating $cmd()\n"; print Dumper \@_; } # This command ('squiggle') has two aliases ('foo', 'bar'). It doesn't have a # summary or a help topic. It does provide custom command completion, though. # If you try to complete the line after typing 'squiggle' (or 'foo' or 'bar'), # you will be able to complete to any of the words qw(all work and no play is # no fun at). Just for fun. sub run_squiggle { print "Squiggle!\n"; return 42; } sub comp_squiggle { my $o = shift; my $word = shift; $o->{SHELL}{num}++; $o->completions( $word, [qw(all work and no play is no fun at)] ); } sub alias_squiggle { qw(foo bar) } # You can override the prompt sub prompt_str { my $o = shift; $o->{SHELL}{num}++; "test:$o->{SHELL}{num}> "; } sub run_attribs { my $o = shift; my $term = $o->term; print Dumper $term->Features; my @keys = qw( readline_name basic_word_break_characters ); print Dumper $term->Attribs->{$_} for @keys; } package main; if ( $ENV{TEST_INTERACTIVE} or not( exists $ENV{MAKELEVEL} or exists $ENV{__MKLVL__} ) ) { print <new('default'); my $term = $app->term; warn "Using term $term\n"; $app->cmdloop; } else { print <lines_utf8() ); if ( !defined($version) ) { die "Version is undefined!"; } my @cmd = ( "git", "tag", "-m", "Tagging Term-Shell as $version", $version, ); print join( " ", map { /\s/ ? qq{"$_"} : $_ } @cmd ), "\n"; exec(@cmd); pod-syntax.t100644000764000764 25214134244454 20203 0ustar00shlomifshlomif000000000000Term-Shell-0.13/xt/author#!perl # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use strict; use warnings; use Test::More; use Test::Pod 1.41; all_pod_files_ok(); cpan-changes.t100644000764000764 34414134244454 20544 0ustar00shlomifshlomif000000000000Term-Shell-0.13/xt/releaseuse strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::CPAN::Changes 0.012 use Test::More 0.96 tests => 1; use Test::CPAN::Changes; subtest 'changes_ok' => sub { changes_file_ok('Changes'); }; trailing-space.t100644000764000764 103414134244454 21134 0ustar00shlomifshlomif000000000000Term-Shell-0.13/xt/release#!perl use strict; use warnings; use Test::More; eval "use Test::TrailingSpace"; if ($@) { plan skip_all => "Test::TrailingSpace required for trailing space test."; } else { plan tests => 1; } # TODO: add .pod, .PL, the README/Changes/TODO/etc. documents and possibly # some other stuff. my $finder = Test::TrailingSpace->new( { root => '.', filename_regex => qr#(?:\.(?:t|pm|pl|xs|c|h|txt|pod|PL)|README|Changes|TODO|LICENSE)\z#, }, ); # TEST $finder->no_trailing_space( "No trailing space was found." ); bump-version-number.pl100644000764000764 116014134244454 21732 0ustar00shlomifshlomif000000000000Term-Shell-0.13/scripts#!/usr/bin/perl use strict; use warnings; use File::Find::Object; use IO::All; my $tree = File::Find::Object->new( {}, 'lib/' ); my $version_n = shift(@ARGV); if ( !defined($version_n) ) { die "Specify version number as an argument! bump-version-number.pl '0.0.1'"; } while ( my $r = $tree->next() ) { if ( $r =~ m{/\.svn\z} ) { $tree->prune(); } elsif ( $r =~ m{\.pm\z} ) { my @lines = io->file($r)->getlines(); foreach (@lines) { s#(\$VERSION = '|^Version )\d+\.\d+(?:\.\d+)?('|)#$1 . $version_n . $2#e; } io->file($r)->print(@lines); } }