This is an automated email from the git hooks/post-receive script. kanashiro-guest pushed a commit to branch master in repository libterm-shell-perl.
commit 0ac6d27a41784ed2a791fee25e1fbcd6a17b3b37 Author: Lucas Kanashiro <kanashiro.dua...@gmail.com> Date: Tue Jan 12 00:08:50 2016 -0200 Imported Upstream version 0.07 --- Build.PL | 110 +++-- Changes | 7 + MANIFEST | 24 +- MANIFEST.SKIP | 1 + META.json | 66 --- META.yml | 36 +- Makefile.PL | 21 - README | 66 +-- _build/auto_features | 2 + _build/build_params | 167 +++++++ _build/cleanup | 10 + _build/config_data | 2 + _build/features | 2 + _build/magicnum | 1 + _build/notes | 2 + _build/prereqs | 18 + _build/runtime_params | 2 + dist.ini | 46 ++ lib/Term/Shell.pm | 1158 +++++++++++++++++++++++++++++++++++++++++++- lib/Term/Shell.pod | 1004 -------------------------------------- scripts/tag-release.pl | 26 + t/00-compile.t | 57 +++ t/03catchsmry.t | 11 +- t/author-pod-syntax.t | 15 + t/release-cpan-changes.t | 19 + t/release-kwalitee.t | 17 + t/release-trailing-space.t | 38 ++ t/style-trailing-space.t | 2 +- weaver.ini | 39 ++ 29 files changed, 1750 insertions(+), 1219 deletions(-) diff --git a/Build.PL b/Build.PL index 8bbfbf9..26dc587 100644 --- a/Build.PL +++ b/Build.PL @@ -1,50 +1,70 @@ + +# This file was automatically generated by Dist::Zilla::Plugin::ModuleBuild v5.040. use strict; use warnings; -use lib "./inc"; - -use Test::Run::Builder; - -my $builder = Test::Run::Builder->new( - module_name => 'Term::Shell', - license => 'perl', - dist_author => q{Shlomi Fish <shlo...@cpan.org>}, - dist_version_from => 'lib/Term/Shell.pm', - requires => - { - 'Data::Dumper' => 0, - 'Term::ReadLine' => 0, - 'perl' => '5.008', - 'strict' => 0, - 'warnings' => 0, - }, - build_requires => - { - 'Test' => 0, - 'Test::More' => 0, - 'vars' => 0, - }, - configure_requires => - { - 'Module::Build' => 0, - }, - add_to_cleanup => [ 'Term-Shell-*' ], - create_makefile_pl => 'traditional', - meta_merge => - { - resources => - { - repository => "https://github.com/shlomif/Term-Shell", - }, - keywords => - [ - 'console', - 'readline', - 'shell', - 'term', - 'terminal', - ], - }, +use Module::Build 0.28; +use lib qw{inc}; use Test::Run::Builder; + +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 <shlomif\@cpan.org>" + ], + "dist_name" => "Term-Shell", + "dist_version" => "0.07", + "license" => "mit", + "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.008", + "strict" => 0, + "vars" => 0, + "warnings" => 0 + }, + "test_requires" => { + "File::Spec" => 0, + "File::Temp" => 0, + "IO::Handle" => 0, + "IPC::Open3" => 0, + "Test::More" => 0, + "base" => 0, + "blib" => "1.01" + } +); + + +my %fallback_build_requires = ( + "File::Spec" => 0, + "File::Temp" => 0, + "IO::Handle" => 0, + "IPC::Open3" => 0, + "Module::Build" => "0.28", + "Test::More" => 0, + "base" => 0, + "blib" => "1.01" ); -$builder->create_build_script(); + +unless ( eval { Module::Build->VERSION(0.4004) } ) { + delete $module_build_args{test_requires}; + $module_build_args{build_requires} = \%fallback_build_requires; +} + +my $build = Test::Run::Builder->new(%module_build_args); + + +$build->create_build_script; diff --git a/Changes b/Changes index 1c571c4..4900489 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,10 @@ +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). diff --git a/MANIFEST b/MANIFEST index bcbf3cb..88bea68 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,20 +1,36 @@ +# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.040. Build.PL Changes LICENSE MANIFEST -META.json -META.yml Module meta-data (added by MakeMaker) -Makefile.PL +MANIFEST.SKIP +META.yml README +_build/auto_features +_build/build_params +_build/cleanup +_build/config_data +_build/features +_build/magicnum +_build/notes +_build/prereqs +_build/runtime_params +dist.ini examples/old-test.pl examples/psh.pl inc/Test/Run/Builder.pm lib/Term/Shell.pm -lib/Term/Shell.pod scripts/bump-version-number.pl +scripts/tag-release.pl +t/00-compile.t t/01require.t t/02default.t t/03catchsmry.t +t/author-pod-syntax.t t/cpan-changes.t t/pod.t +t/release-cpan-changes.t +t/release-kwalitee.t +t/release-trailing-space.t t/style-trailing-space.t +weaver.ini diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP new file mode 100644 index 0000000..2e58f07 --- /dev/null +++ b/MANIFEST.SKIP @@ -0,0 +1 @@ +~$ diff --git a/META.json b/META.json deleted file mode 100644 index 506cded..0000000 --- a/META.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "abstract" : "A simple command-line shell framework.", - "author" : [ - "Shlomi Fish <shlo...@cpan.org>" - ], - "dynamic_config" : 1, - "generated_by" : "Module::Build version 0.4205", - "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" : { - "Test" : "0", - "Test::More" : "0", - "vars" : "0" - } - }, - "configure" : { - "requires" : { - "Module::Build" : "0" - } - }, - "runtime" : { - "requires" : { - "Data::Dumper" : "0", - "Term::ReadLine" : "0", - "perl" : "5.008", - "strict" : "0", - "warnings" : "0" - } - } - }, - "provides" : { - "Term::Shell" : { - "file" : "lib/Term/Shell.pm", - "version" : "0.06" - }, - "Term::Shell::OnScopeLeave" : { - "file" : "lib/Term/Shell.pm", - "version" : "0.06" - } - }, - "release_status" : "stable", - "resources" : { - "license" : [ - "http://dev.perl.org/licenses/" - ], - "repository" : { - "url" : "https://github.com/shlomif/Term-Shell" - } - }, - "version" : "0.06" -} diff --git a/META.yml b/META.yml index e328a44..0a4c7ac 100644 --- a/META.yml +++ b/META.yml @@ -3,38 +3,42 @@ abstract: 'A simple command-line shell framework.' author: - 'Shlomi Fish <shlo...@cpan.org>' build_requires: - Test: '0' + File::Spec: '0' + File::Temp: '0' + IO::Handle: '0' + IPC::Open3: '0' + Module::Build: '0.28' Test::More: '0' - vars: '0' + base: '0' + blib: '1.01' configure_requires: - Module::Build: '0' -dynamic_config: 1 -generated_by: 'Module::Build version 0.4205, CPAN::Meta::Converter version 2.140640' + Module::Build: '0.28' +dynamic_config: 0 +generated_by: 'Dist::Zilla version 5.040, CPAN::Meta::Converter version 2.150005' keywords: - console - readline - shell - term - terminal -license: perl +license: mit 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.06' - Term::Shell::OnScopeLeave: - file: lib/Term/Shell.pm - version: '0.06' 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.008' strict: '0' + vars: '0' warnings: '0' resources: - license: http://dev.perl.org/licenses/ - repository: https://github.com/shlomif/Term-Shell -version: '0.06' + bugtracker: http://rt.cpan.org/NoAuth/Bugs.html?Dist=Games-Solitaire-Verify + repository: git://g...@github.com:shlomif/Term-Shell.git +version: '0.07' diff --git a/Makefile.PL b/Makefile.PL deleted file mode 100644 index d8f7e93..0000000 --- a/Makefile.PL +++ /dev/null @@ -1,21 +0,0 @@ -# Note: this file was auto-generated by Module::Build::Compat version 0.4205 -require 5.008; -use ExtUtils::MakeMaker; -WriteMakefile -( - 'NAME' => 'Term::Shell', - 'VERSION_FROM' => 'lib/Term/Shell.pm', - 'PREREQ_PM' => { - 'Data::Dumper' => 0, - 'Term::ReadLine' => 0, - 'Test' => 0, - 'Test::More' => 0, - 'strict' => 0, - 'vars' => 0, - 'warnings' => 0 - }, - 'INSTALLDIRS' => 'site', - 'EXE_FILES' => [], - 'PL_FILES' => {} -) -; diff --git a/README b/README index c7f31ff..70dd5e1 100644 --- a/README +++ b/README @@ -1,68 +1,16 @@ -INTRODUCTION -Term::Shell -- Write command-line shells in Perl. -Term::Shell makes it joyfully easy to write command-line interfaces in Perl. -All the boring details like command-line parsing and terminal handling are -done for you. +This archive contains the distribution Term-Shell, +version 0.07: -Example: + A simple command-line shell framework. - package MyShell; - use base qw(Term::Shell); +This software is Copyright (c) 2014 by Shlomi Fish. - # This behaves like the system echo command, minus shell expansion - sub run_echo { - my $o = shift; - print "@_\n" if @_; # print the arguments - } +This is free software, licensed under: - package main; - MyShell->new->cmdloop; + The MIT (X11) License -Here is a sample session from this program: - shell> help - Type 'help command' for more detailed help on a command. - Commands: - echo - undocumented - no help available - exit - exits the program - help - prints this screen, or help on 'command' - shell> echo - shell> echo 1 2 3 - 1 2 3 - shell> echo $VAR - $VAR - shell> exit +This README file was generated by Dist::Zilla::Plugin::Readme v5.040. ------------------------------------------------------------------------------- -INSTALLATION: - -This module requires Term::ReadLine to be installed. This module has been a -core module since at least 5.005_03, so it shouldn't be a problem. - -This module requires Text::Autoformat for some features. Text::Autoformat can -be found on your nearest CPAN mirror, probably the same place you got -Term::Shell. - -To install Term::Shell do this: - -perl Makefile.PL -make -make test -make install - -(On ActivePerl for MSWin32, use nmake instead of make.) - -You have to 'make install' before you can run it successfully. - ------------------------------------------------------------------------------- -INFORMATION: - -- For more information on Term::Shell see 'perldoc Term::Shell'. -- For more information on Term::ReadLine see 'perldoc Term::ReadLine'. -- For more information on Text::Autoformat see 'perldoc Text::Autoformat'. - -Please send questions and comments to "Neil Watkiss" <ne...@cpan.org> - -Copyright (c) 2002, Neil Watkiss. All Rights Reserved. diff --git a/_build/auto_features b/_build/auto_features new file mode 100644 index 0000000..2df4e46 --- /dev/null +++ b/_build/auto_features @@ -0,0 +1,2 @@ +do{ my $x = {}; +$x; } \ No newline at end of file diff --git a/_build/build_params b/_build/build_params new file mode 100644 index 0000000..64b6545 --- /dev/null +++ b/_build/build_params @@ -0,0 +1,167 @@ +do{ my $x = [ + { + 'ARGV' => [] + }, + {}, + { + 'PL_files' => undef, + '_added_to_INC' => [ + './inc', + '/home/shlomif/apps/perl/modules/lib/perl5/site_perl/5.22.0/x86_64-linux-thread-multi', + '/home/shlomif/apps/perl/modules/lib/perl5/site_perl/5.22.0', + '/home/shlomif/apps/perl/modules/lib/site_perl/5.22.0', + '/home/shlomif/apps/perl/modules/lib/perl5/5.22.0/x86_64-linux-thread-multi', + '/home/shlomif/apps/perl/modules/lib/perl5/5.22.0', + '/home/shlomif/apps/perl/modules/lib/perl5/site_perl/5.20.1/x86_64-linux-thread-multi', + '/home/shlomif/apps/perl/modules/lib/perl5/site_perl/5.20.1', + '/home/shlomif/apps/perl/modules/lib/site_perl/5.20.1', + '/home/shlomif/apps/perl/modules/lib/perl5/5.20.1/x86_64-linux-thread-multi', + '/home/shlomif/apps/perl/modules/lib/perl5/5.20.1', + '/home/shlomif/apps/perl/modules/lib/perl5/site_perl/5.20.0/x86_64-linux-thread-multi', + '/home/shlomif/apps/perl/modules/lib/perl5/site_perl/5.20.0', + '/home/shlomif/apps/perl/modules/lib/site_perl/5.20.0', + '/home/shlomif/apps/perl/modules/lib/perl5/5.20.0', + '/home/shlomif/apps/perl/modules/lib/perl5/site_perl/5.18.2/x86_64-linux-thread-multi', + '/home/shlomif/apps/perl/modules/lib/perl5/site_perl/5.18.2', + '/home/shlomif/apps/perl/modules/lib/site_perl/5.18.2', + '/home/shlomif/apps/perl/modules/lib/perl5/5.18.2', + '/home/shlomif/apps/perl/modules/lib/perl5/site_perl/5.18.1', + '/home/shlomif/apps/perl/modules/lib/site_perl/5.18.1', + '/home/shlomif/apps/perl/modules/lib/perl5/5.18.1' + ], + 'allow_mb_mismatch' => 0, + 'allow_pureperl' => 0, + 'auto_configure_requires' => 1, + 'autosplit' => undef, + 'base_dir' => '/home/shlomif/progs/perl/cpan/Term/Shell/Term-Shell', + 'bindoc_dirs' => [ + 'blib/script' + ], + 'blib' => 'blib', + 'build_bat' => 0, + 'build_class' => 'Test::Run::Builder', + 'build_elements' => [ + 'PL', + 'support', + 'pm', + 'xs', + 'share_dir', + 'pod', + 'script' + ], + 'build_requires' => { + 'Test' => 0, + 'Test::More' => 0, + 'vars' => 0 + }, + 'build_script' => 'Build', + 'bundle_inc' => [], + 'bundle_inc_preload' => [], + 'c_source' => undef, + 'config' => undef, + 'config_dir' => '_build', + 'configure_requires' => { + 'Module::Build' => 0 + }, + 'conflicts' => {}, + 'cpan_client' => 'cpan', + 'create_license' => undef, + 'create_makefile_pl' => 'traditional', + 'create_packlist' => 1, + 'create_readme' => undef, + 'debug' => undef, + 'debugger' => undef, + 'destdir' => undef, + 'dist_abstract' => undef, + 'dist_author' => [ + 'Shlomi Fish <shlo...@cpan.org>' + ], + 'dist_name' => 'Term-Shell', + 'dist_suffix' => undef, + 'dist_version' => '0.06', + 'dist_version_from' => 'lib/Term/Shell.pm', + 'dynamic_config' => 1, + 'extra_compiler_flags' => [], + 'extra_linker_flags' => [], + 'extra_manify_args' => undef, + 'get_options' => {}, + 'has_config_data' => undef, + 'html_css' => '', + 'include_dirs' => [], + 'install_base' => undef, + 'install_base_relpaths' => {}, + 'install_path' => {}, + 'install_sets' => {}, + 'installdirs' => 'site', + 'libdoc_dirs' => [ + 'blib/lib', + 'blib/arch' + ], + 'license' => 'perl', + 'magic_number' => undef, + 'mb_version' => '0.4214', + 'meta_add' => {}, + 'meta_merge' => { + 'keywords' => [ + 'console', + 'readline', + 'shell', + 'term', + 'terminal' + ], + 'resources' => { + 'repository' => 'https://github.com/shlomif/Term-Shell' + } + }, + 'metafile' => 'META.yml', + 'metafile2' => 'META.json', + 'module_name' => 'Term::Shell', + 'mymetafile' => 'MYMETA.yml', + 'mymetafile2' => 'MYMETA.json', + 'needs_compiler' => '', + 'orig_dir' => '/home/shlomif/progs/perl/cpan/Term/Shell/Term-Shell', + 'original_prefix' => {}, + 'perl' => '/usr/bin/perl5.22.0', + 'pm_files' => undef, + 'pod_files' => undef, + 'pollute' => undef, + 'prefix' => undef, + 'prefix_relpaths' => {}, + 'prereq_action_types' => [ + 'requires', + 'build_requires', + 'test_requires', + 'conflicts', + 'recommends' + ], + 'program_name' => undef, + 'pureperl_only' => 0, + 'quiet' => undef, + 'recommends' => {}, + 'recurse_into' => [], + 'recursive_test_files' => undef, + 'release_status' => 'stable', + 'requires' => { + 'Data::Dumper' => 0, + 'Term::ReadLine' => 0, + 'perl' => '5.008', + 'strict' => 0, + 'warnings' => 0 + }, + 'script_files' => undef, + 'scripts' => undef, + 'share_dir' => undef, + 'sign' => undef, + 'tap_harness_args' => {}, + 'test_file_exts' => [ + '.t' + ], + 'test_files' => undef, + 'test_requires' => {}, + 'use_rcfile' => 1, + 'use_tap_harness' => 0, + 'verbose' => undef, + 'xs_files' => undef + } + ]; +$x; } \ No newline at end of file diff --git a/_build/cleanup b/_build/cleanup new file mode 100644 index 0000000..68c2ecd --- /dev/null +++ b/_build/cleanup @@ -0,0 +1,10 @@ +do{ my $x = { + 'Term-Shell-0.06' => 1, + 'Term-Shell-0.02' => 1, + 'Term-Shell-0.05' => 1, + 'Term-Shell-*' => 1, + 'Term-Shell-0.04' => 1, + 'Term-Shell-0.03' => 1, + 'blib' => 1 + }; +$x; } \ No newline at end of file diff --git a/_build/config_data b/_build/config_data new file mode 100644 index 0000000..2df4e46 --- /dev/null +++ b/_build/config_data @@ -0,0 +1,2 @@ +do{ my $x = {}; +$x; } \ No newline at end of file diff --git a/_build/features b/_build/features new file mode 100644 index 0000000..2df4e46 --- /dev/null +++ b/_build/features @@ -0,0 +1,2 @@ +do{ my $x = {}; +$x; } \ No newline at end of file diff --git a/_build/magicnum b/_build/magicnum new file mode 100644 index 0000000..c0cb706 --- /dev/null +++ b/_build/magicnum @@ -0,0 +1 @@ +210417 \ No newline at end of file diff --git a/_build/notes b/_build/notes new file mode 100644 index 0000000..2df4e46 --- /dev/null +++ b/_build/notes @@ -0,0 +1,2 @@ +do{ my $x = {}; +$x; } \ No newline at end of file diff --git a/_build/prereqs b/_build/prereqs new file mode 100644 index 0000000..a2a9ac2 --- /dev/null +++ b/_build/prereqs @@ -0,0 +1,18 @@ +do{ my $x = { + 'build_requires' => { + 'Test' => 0, + 'Test::More' => 0, + 'vars' => 0 + }, + 'conflicts' => {}, + 'recommends' => {}, + 'requires' => { + 'Data::Dumper' => 0, + 'Term::ReadLine' => 0, + 'perl' => '5.008', + 'strict' => 0, + 'warnings' => 0 + }, + 'test_requires' => {} + }; +$x; } \ No newline at end of file diff --git a/_build/runtime_params b/_build/runtime_params new file mode 100644 index 0000000..2df4e46 --- /dev/null +++ b/_build/runtime_params @@ -0,0 +1,2 @@ +do{ my $x = {}; +$x; } \ No newline at end of file diff --git a/dist.ini b/dist.ini new file mode 100644 index 0000000..6c4e288 --- /dev/null +++ b/dist.ini @@ -0,0 +1,46 @@ +name = Term-Shell +author = Shlomi Fish <shlo...@cpan.org> +license = MIT +copyright_holder = Shlomi Fish +copyright_year = 2014 + +[@Filter] +-bundle = @Basic +-remove = MakeMaker +-remove = License +[AutoPrereqs] +skip = ^Term::InKey$ +skip = ^Term::Screen$ +skip = ^Term::Size$ +skip = ^Win32::Console$ +[ExecDir] +dir = bin +[Keywords] +keyword = console +keyword = readline +keyword = shell +keyword = term +keyword = terminal +[ModuleBuild] +mb_class = Test::Run::Builder +testing_command = runtest +[PodSyntaxTests] +; [PodCoverageTests] +[Prereqs / Runtime] +-phase = runtime +Getopt::Long = 2.36 +[MetaResources] +bugtracker.web = http://rt.cpan.org/NoAuth/Bugs.html?Dist=Games-Solitaire-Verify +bugtracker.mailto = bug-term-sh...@rt.cpan.org +repository.url = git://g...@github.com:shlomif/Term-Shell.git +repository.web = https://github.com/shlomif/Term-Shell +repository.type = git +[PodWeaver] +[Test::Compile] +fake_home = 1 +skip = bump-ver +[Test::CPAN::Changes] +[Test::Kwalitee] +[Test::TrailingSpace] +filename_regex = (?:(?:\.(?:t|pm|pl|PL|yml|json|arc|vim))|README|Changes|LICENSE)\z +[VersionFromModule] diff --git a/lib/Term/Shell.pm b/lib/Term/Shell.pm index 5952f6f..b2beea7 100644 --- a/lib/Term/Shell.pm +++ b/lib/Term/Shell.pm @@ -10,7 +10,7 @@ use Term::ReadLine; use vars qw($VERSION); -$VERSION = '0.06'; +$VERSION = '0.07'; #============================================================================= # Term::Shell API methods @@ -915,7 +915,7 @@ package Term::Shell::OnScopeLeave; use vars qw($VERSION); -$VERSION = '0.06'; +$VERSION = '0.07'; sub new { return bless [@_[1 .. $#_]], ref($_[0]) || $_[0]; @@ -931,3 +931,1157 @@ sub DESTROY { } 1; + +__END__ + +=pod + +=encoding utf-8 + +=head1 NAME + +Term::Shell - A simple command-line shell framework. + +=head1 VERSION + +version 0.07 + +=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<exec> 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<exec> 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<MyShell> 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<MyShell.pm>, +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<foo>, Term::Shell needs a method called C<run_foo()>, +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<run_> 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<foo> 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<run_()>, Term::Shell will call it +whenever the user enters a blank line. A blank line is anything which matches +the regular expression C</^\s*$/>. + +=item 2 + +help_foo() + +Adds the command C<foo> 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<help_foo()> method, typing 'help foo' produces an +error message. + +=item 3 + +smry_foo() + +Should return a one-line summary of C<foo>, 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<smry_foo()> method, then the string 'undocumented' +is used instead. + +=item 4 + +comp_foo() + +Provides custom tab-completion for C<foo>. That means if the user types 'foo ' +and then hits <TAB>, 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<comp_foo()>, Term::Shell will always return no +completions for C<foo>. + +Special case: if you provide C<comp_()>, Term::Shell will call it when the +user is trying to complete the name of a command. Term::Shell provides a +default C<comp_()> 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<comp_()>. + +=item 5 + +alias_foo() + +Returns a list of aliases for C<foo>. When one of the aliases is used instead +of C<foo>, the corresponding handler for C<foo> 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<catch_> 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<catch_run> routine and do +the same thing from there. You'd have to override C<comp_> 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<and> +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<exit> and C<help>) +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<help> 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<exit> 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<help> command to see what's available. If you +remove the C<help> 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) = @_; + <<END; + Unknown command '$cmd'; type 'help' for a list of commands. + END + } + +=item 2 + +msg_ambiguous_cmd() + +Called when the user has entered a command for which more than handler exists. +(For example, if both "quit" and "query" are commands, then "qu" is an +ambiguous command, because it could be either.) It receives the object, the +command, and the possible commands which could complete it. It should return +an error message; by default it is defined thusly: + + sub msg_ambiguous_cmd { + my ($o, $cmd, @c) = @_; + local $" = "\n\t"; + <<END; + Ambiguous command '$cmd': possible commands: + @c + END + } + +=back + +=head1 The Term::Shell API + +Shell classes can use any of the methods in this list. Any other methods in +Term::Shell may change. + +=over 4 + +=item 1 + +new() + +Creates a new Term::Shell object. It currently does not use its arguments. The +arguments are saved in '$o->{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<cmd()> 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<check_idle> to a non-zero number (see L<The Term::Shell Object>) +then this method is called every C<check_idle> 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 <TAB>, 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<FoO> and +C<foo> 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<run_foo()> 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<Term::ReadLine> 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<abc"def>. + +=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<Adding Commands to Your Shell> for information on add_handlers(). + +=item 22 + +remove_commands() + +remove_handlers() + +See L<Removing Commands from Your Shell> 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<FoO> will have the same effect as typing +C<foo>. + +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<your> shell, it's their +class. + +=head2 The command Attribute + +Whenever Term::Shell invokes an action, it stores information about the action +in the C<command> 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<last> 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<run_foo()> calls C<run_add()>, 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<foo> and +C<bar> defined, the user can type C<f> to run C<foo>, and C<b> to run C<bar>. + +Defaults to true. + +=head2 The readline Attribute + +Which Term::ReadLine module is being used. Currently, this is always one of +C<Term::ReadLine::Stub>, C<Term::ReadLine::Perl>, or C<Term::ReadLine::Gnu>. + +=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 BUGS AND DEFICIENCIES + +There are bound to be some bugs lurking about. + +If you find bugs, please send them to C<ne...@cpan.org>. + +=head1 SEE ALSO + +For more information about the underlying ReadLine module, see +L<Term::ReadLine>. You may also want to look at L<Term::ReadLine::Gnu> and +L<Term::ReadLine::Perl>. + +For more information about the underlying formatter used by print_pairs(), see +L<Text::Autoformat>. + +The API for Term::Shell was inspired by (gasp!) a Python package called +C<cmd>. For more information about this package, please look in the Python +Library Reference, either in your Python distribution or at +http://www.python.org/doc/current/lib/module-cmd.html + +=head1 AUTHOR + +Neil Watkiss (ne...@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 + +=head1 AUTHOR + +Shlomi Fish <shlo...@cpan.org> + +=head1 COPYRIGHT AND LICENSE + +This software is Copyright (c) 2014 by Shlomi Fish. + +This is free software, licensed under: + + The MIT (X11) License + +=head1 BUGS + +Please report any bugs or feature requests on the bugtracker website +http://rt.cpan.org/NoAuth/Bugs.html?Dist=Games-Solitaire-Verify or by email +to bug-term-sh...@rt.cpan.org. + +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. + +=for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan + +=head1 SUPPORT + +=head2 Perldoc + +You can find documentation for this module with the perldoc command. + + perldoc Term::Shell + +=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<http://metacpan.org/release/Term-Shell> + +=item * + +Search CPAN + +The default CPAN search engine, useful to view POD in HTML format. + +L<http://search.cpan.org/dist/Term-Shell> + +=item * + +RT: CPAN's Bug Tracker + +The RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN. + +L<https://rt.cpan.org/Public/Dist/Display.html?Name=Term-Shell> + +=item * + +AnnoCPAN + +The AnnoCPAN is a website that allows community annotations of Perl module documentation. + +L<http://annocpan.org/dist/Term-Shell> + +=item * + +CPAN Ratings + +The CPAN Ratings is a website that allows community ratings and reviews of Perl modules. + +L<http://cpanratings.perl.org/d/Term-Shell> + +=item * + +CPAN Forum + +The CPAN Forum is a web forum for discussing Perl modules. + +L<http://cpanforum.com/dist/Term-Shell> + +=item * + +CPANTS + +The CPANTS is a website that analyzes the Kwalitee ( code metrics ) of a distribution. + +L<http://cpants.cpanauthors.org/dist/Term-Shell> + +=item * + +CPAN Testers + +The CPAN Testers is a network of smokers who run automated tests on uploaded CPAN distributions. + +L<http://www.cpantesters.org/distro/T/Term-Shell> + +=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<http://matrix.cpantesters.org/?dist=Term-Shell> + +=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<http://deps.cpantesters.org/?module=Term::Shell> + +=back + +=head2 Bugs / Feature Requests + +Please report any bugs or feature requests by email to C<bug-term-shell at rt.cpan.org>, or through +the web interface at L<https://rt.cpan.org/Public/Bug/Report.html?Queue=Term-Shell>. 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<https://github.com/shlomif/Term-Shell> + + git clone git://g...@github.com:shlomif/Term-Shell.git + +=cut diff --git a/lib/Term/Shell.pod b/lib/Term/Shell.pod deleted file mode 100644 index 112b049..0000000 --- a/lib/Term/Shell.pod +++ /dev/null @@ -1,1004 +0,0 @@ -=head1 NAME - -Term::Shell - A simple command-line shell framework. - -=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<exec> 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<exec> 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<MyShell> 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<MyShell.pm>, -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<foo>, Term::Shell needs a method called C<run_foo()>, -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<run_> 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<foo> 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<run_()>, Term::Shell will call it -whenever the user enters a blank line. A blank line is anything which matches -the regular expression C</^\s*$/>. - -=item 2 - -help_foo() - -Adds the command C<foo> 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<help_foo()> method, typing 'help foo' produces an -error message. - -=item 3 - -smry_foo() - -Should return a one-line summary of C<foo>, 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<smry_foo()> method, then the string 'undocumented' -is used instead. - -=item 4 - -comp_foo() - -Provides custom tab-completion for C<foo>. That means if the user types 'foo ' -and then hits <TAB>, 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<comp_foo()>, Term::Shell will always return no -completions for C<foo>. - -Special case: if you provide C<comp_()>, Term::Shell will call it when the -user is trying to complete the name of a command. Term::Shell provides a -default C<comp_()> 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<comp_()>. - -=item 5 - -alias_foo() - -Returns a list of aliases for C<foo>. When one of the aliases is used instead -of C<foo>, the corresponding handler for C<foo> 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<catch_> 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<catch_run> routine and do -the same thing from there. You'd have to override C<comp_> 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<and> -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<exit> and C<help>) -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<help> 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<exit> 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<help> command to see what's available. If you -remove the C<help> 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) = @_; - <<END; - Unknown command '$cmd'; type 'help' for a list of commands. - END - } - -=item 2 - -msg_ambiguous_cmd() - -Called when the user has entered a command for which more than handler exists. -(For example, if both "quit" and "query" are commands, then "qu" is an -ambiguous command, because it could be either.) It receives the object, the -command, and the possible commands which could complete it. It should return -an error message; by default it is defined thusly: - - sub msg_ambiguous_cmd { - my ($o, $cmd, @c) = @_; - local $" = "\n\t"; - <<END; - Ambiguous command '$cmd': possible commands: - @c - END - } - -=back - -=head1 The Term::Shell API - -Shell classes can use any of the methods in this list. Any other methods in -Term::Shell may change. - -=over 4 - -=item 1 - -new() - -Creates a new Term::Shell object. It currently does not use its arguments. The -arguments are saved in '$o->{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<cmd()> 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<check_idle> to a non-zero number (see L<The Term::Shell Object>) -then this method is called every C<check_idle> 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 <TAB>, 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<FoO> and -C<foo> 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<run_foo()> 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<Term::ReadLine> 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<abc"def>. - -=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<Adding Commands to Your Shell> for information on add_handlers(). - -=item 22 - -remove_commands() - -remove_handlers() - -See L<Removing Commands from Your Shell> 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<FoO> will have the same effect as typing -C<foo>. - -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<your> shell, it's their -class. - -=head2 The command Attribute - -Whenever Term::Shell invokes an action, it stores information about the action -in the C<command> 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<last> 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<run_foo()> calls C<run_add()>, 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<foo> and -C<bar> defined, the user can type C<f> to run C<foo>, and C<b> to run C<bar>. - -Defaults to true. - -=head2 The readline Attribute - -Which Term::ReadLine module is being used. Currently, this is always one of -C<Term::ReadLine::Stub>, C<Term::ReadLine::Perl>, or C<Term::ReadLine::Gnu>. - -=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 BUGS AND DEFICIENCIES - -There are bound to be some bugs lurking about. - -If you find bugs, please send them to C<ne...@cpan.org>. - -=head1 SEE ALSO - -For more information about the underlying ReadLine module, see -L<Term::ReadLine>. You may also want to look at L<Term::ReadLine::Gnu> and -L<Term::ReadLine::Perl>. - -For more information about the underlying formatter used by print_pairs(), see -L<Text::Autoformat>. - -The API for Term::Shell was inspired by (gasp!) a Python package called -C<cmd>. For more information about this package, please look in the Python -Library Reference, either in your Python distribution or at -http://www.python.org/doc/current/lib/module-cmd.html - -=head1 AUTHOR - -Neil Watkiss (ne...@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 diff --git a/scripts/tag-release.pl b/scripts/tag-release.pl new file mode 100644 index 0000000..d94956e --- /dev/null +++ b/scripts/tag-release.pl @@ -0,0 +1,26 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use IO::All; + +my ($version) = + (map { m{\$VERSION *= *'([^']+)'} ? ($1) : () } + io->file("./lib/Term/Shell.pm")->getlines() + ) + ; + +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); diff --git a/t/00-compile.t b/t/00-compile.t new file mode 100644 index 0000000..a943480 --- /dev/null +++ b/t/00-compile.t @@ -0,0 +1,57 @@ +use 5.006; +use strict; +use warnings; + +# this test was generated with Dist::Zilla::Plugin::Test::Compile 2.054 + +use Test::More; + +plan tests => 1 + ($ENV{AUTHOR_TESTING} ? 1 : 0); + +my @module_files = ( + 'Term/Shell.pm' +); + + + +# fake home for cpan-testers +use File::Temp; +local $ENV{HOME} = File::Temp::tempdir( CLEANUP => 1 ); + + +my $inc_switch = -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<perlfaq8/How can I capture STDERR from an external command?> + my $stderr = IO::Handle->new; + + my $pid = open3($stdin, '>&STDERR', $stderr, $^X, $inc_switch, '-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}; + + diff --git a/t/03catchsmry.t b/t/03catchsmry.t index 2f9ee96..fce28f2 100644 --- a/t/03catchsmry.t +++ b/t/03catchsmry.t @@ -1,7 +1,16 @@ use strict; use warnings; -use Test::More tests => 1; +use Test::More; + +if ($^O eq 'MSWin32') +{ + plan skip_all => "Test gets stuck on Windows - RT #40771"; +} +else +{ + plan tests => 1; +} require Term::Shell; diff --git a/t/author-pod-syntax.t b/t/author-pod-syntax.t new file mode 100644 index 0000000..35fb1b9 --- /dev/null +++ b/t/author-pod-syntax.t @@ -0,0 +1,15 @@ +#!perl + +BEGIN { + unless ($ENV{AUTHOR_TESTING}) { + require Test::More; + Test::More::plan(skip_all => 'these tests are for testing by the author'); + } +} + +# 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(); diff --git a/t/release-cpan-changes.t b/t/release-cpan-changes.t new file mode 100644 index 0000000..214650f --- /dev/null +++ b/t/release-cpan-changes.t @@ -0,0 +1,19 @@ +#!perl + +BEGIN { + unless ($ENV{RELEASE_TESTING}) { + require Test::More; + Test::More::plan(skip_all => 'these tests are for release candidate testing'); + } +} + + +use strict; +use warnings; + +use Test::More 0.96 tests => 2; +use_ok('Test::CPAN::Changes'); +subtest 'changes_ok' => sub { + changes_file_ok('Changes'); +}; +done_testing(); diff --git a/t/release-kwalitee.t b/t/release-kwalitee.t new file mode 100644 index 0000000..00738b8 --- /dev/null +++ b/t/release-kwalitee.t @@ -0,0 +1,17 @@ + +BEGIN { + unless ($ENV{RELEASE_TESTING}) { + require Test::More; + Test::More::plan(skip_all => 'these tests are for release candidate testing'); + } +} + +# this test was generated with Dist::Zilla::Plugin::Test::Kwalitee 2.12 +use strict; +use warnings; +use Test::More 0.88; +use Test::Kwalitee 1.21 'kwalitee_ok'; + +kwalitee_ok(); + +done_testing; diff --git a/t/release-trailing-space.t b/t/release-trailing-space.t new file mode 100644 index 0000000..3e8b540 --- /dev/null +++ b/t/release-trailing-space.t @@ -0,0 +1,38 @@ +#!perl + +BEGIN { + unless ($ENV{RELEASE_TESTING}) { + require Test::More; + Test::More::plan(skip_all => 'these tests are for release candidate testing'); + } +} + + +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|PL|yml|json|arc|vim))|README|Changes|LICENSE)\z#, + }, +); + +# TEST +$finder->no_trailing_space( + "No trailing space was found." +); diff --git a/t/style-trailing-space.t b/t/style-trailing-space.t index 0d1459a..170d19f 100644 --- a/t/style-trailing-space.t +++ b/t/style-trailing-space.t @@ -18,7 +18,7 @@ else my $finder = Test::TrailingSpace->new( { root => '.', - filename_regex => qr/(?:(?:\.(?:t|pm|pl|PL|yml|json|arc|vim))|README|Changes|LICENSE)\z/, + filename_regex => qr/(?:(?:\.(?:t|pm|pl|pod|PL|yml|json|arc|vim))|README|Changes|LICENSE)\z/, }, ); diff --git a/weaver.ini b/weaver.ini new file mode 100644 index 0000000..228ad8e --- /dev/null +++ b/weaver.ini @@ -0,0 +1,39 @@ +[@CorePrep] + +[-SingleEncoding] + +[Generic / NAME] + +[Version] + +[Region / prelude] + + +[Generic / SYNOPSIS] +[Generic / DESCRIPTION] +[Generic / OVERVIEW] + +[Collect / ATTRIBUTES] +command = attr + +[Collect / METHODS] +command = method + +[Leftovers] + +[Region / postlude] + +[Authors] +[Legal] + +; [Generic / DESCRIPTION] +; required = 1 + +; [Generic / BUGS] + +; [Generic / Section::Bugs] +; [Generic / Section::License] +; +[Bugs] +[Support] +all_modules = 1 -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libterm-shell-perl.git _______________________________________________ Pkg-perl-cvs-commits mailing list Pkg-perl-cvs-commits@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits