NAME

App::CLI::Plugin::StackTrace - for App::CLI::Extension error stacktrace module

SYNOPSIS

  # MyApp.pm
  package MyApp;
  
  use strict;
  use base qw(App::CLI::Extension);
  
  # extension method
  __PACKAGE__->load_plugins(qw(StackTrace));

  __PACKAGE__->config(stacktrace => { enable => 1 });
  
  1;
  
  # MyApp/Hello.pm
  package MyApp::Hello;
  use strict;
  use feature ":5.10.0";
  use base qw(App::CLI::Command);
  
  sub run {
  
      my($self, @args) = @_;
	  my $x = 1;
	  my $y = 0;
	  my $res = $x / $y;
  }
  
  sub fail {
  
      my($self, @args) = @_;
	  print $self->errstr;
	  $self->exit_value(1);
  }
  
  # myapp
  #!/usr/bin/perl
  
  use strict;
  use MyApp;
  
  MyApp->dispatch;
  
  # execute
  [kurt@localhost ~] ./myapp hello
  MyApp::Hello
  
    Illegal division by zero at /root/perl-work/lib/MyApp/Hello.pm line 12.
  
  
  ----------
    MyApp::Hello at /root/perl-work/lib/MyApp/Hello.pm line 12.
  
      00007: sub run {
      00008: 
      00009: 	my($self, @argv) = @_;
      00010: 	my $x = 1;
      00011: 	my $y = 0;
    * 00012: 	my $res = $x / $y;
      00013: }
      00014: 
      00015: sub fail {
      00016: 
      00017: 	my($self, @argv) = @_;
  
    ==========
    App::CLI::Extension::Component::RunCommand at /usr/lib/perl5/site_perl/5.8.8/App/CLI/Extension/Component/RunCommand.pm line 32.
  
      00027: 	my($self, @argv) = @_;
      00028: 
      00029: 	eval {
      00030: 		$self->setup(@argv);
      00031: 		$self->prerun(@argv);
    * 00032: 		$self->run(@argv);
      00033: 		$self->postrun(@argv);
      00034: 	};
      00035: 	if ($@) {
      00036: 		chomp(my $message = $@);
      00037: 		$self->errstr($message);
  
    ==========
    App::CLI::Extension::Component::RunCommand at /usr/lib/perl5/site_perl/5.8.8/App/CLI/Extension/Component/RunCommand.pm line 29.
  
      00024: 
      00025: sub run_command {
      00026: 
      00027: 	my($self, @argv) = @_;
      00028: 
    * 00029: 	eval {
      00030: 		$self->setup(@argv);
      00031: 		$self->prerun(@argv);
      00032: 		$self->run(@argv);
      00033: 		$self->postrun(@argv);
      00034: 	};
  
    ==========
    App::CLI::Extension at /usr/lib/perl5/site_perl/5.8.8/App/CLI/Extension.pm line 175.
  
      00170: 		unshift @{"$pkg\::ISA"}, @{$class->_components};
      00171: 		unshift @{"$pkg\::ISA"}, @{$class->_plugins};
      00172: 		$cmd->config($class->_config);
      00173: 		$cmd->orig_argv($class->_orig_argv);
      00174: 	}
    * 00175: 	$cmd->run_command(@ARGV);
      00176: }
      00177: 
      00178: ## I really does not want....
      00179: sub error_cmd {
      00180: 	"Command not recognized, try $0 help.\n";
  
    ==========
    main at myapp.pl line 6.
  
      00001: #!/usr/bin/perl
      00002: 
      00003: use strict;
      00004: use MyApp;
      00005: 
    * 00006: MyApp->dispatch;
    
    ==========
  ----------

DESCRIPTION

App::CLI::Extension stacktrace plugin module

TIPS

How to display the stacktrace

CONFIG

If one is to enable the stacktrace is displayed when an error occurs. If enable is 0 is a normal error message appears when an error occurs

Example:

# MyApp.pm
__PACKAGE__->config(stacktrace => { enable => 1 });

ENVIRON VARIABLE

APPCLI_STACKTRACE_ENABLE environ variable setup. 1: stacktrace 0: normal error message

Example:

export APPCLI_STACKTRACE_ENABLE=1
./myapp hello

OPTION

stacktrace option allows you to specify at runtime, stacktrace can view

Example:

# MyApp/Hello.pm
sub options {
    return(stacktrace => "stacktrace");
}

# MyApp
./myapp --stacktrace hello

AUTHOR

Akira Horimoto

SEE ALSO

App::CLI::Extension

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Copyright (C) 2010 Akira Horimoto