Guest User

Untitled

a guest
Oct 16th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. ### In your base class
  2. package MyApp;
  3. use MooseX::App qw(Config Color);
  4. # Add config file and color-output plugin
  5.  
  6. option 'global_option' => (
  7. is => 'rw',
  8. isa => 'Bool',
  9. documentation => q[Enable this to do fancy stuff],
  10. );
  11.  
  12. # Will not be exposed to the CLI
  13. has 'private_accessor' => (
  14. is => 'rw',
  15. );
  16.  
  17.  
  18. ### Write multiple command classes:
  19. package MyApp::SomeCommand;
  20. use MooseX::App::Command;
  21. extends qw(MyApp); # optional
  22.  
  23. option 'some_option' => (
  24. is => 'rw',
  25. isa => 'Str',
  26. documentation => q[Very important option!],
  27. cmd_aliases => [qw(another)],
  28. );
  29.  
  30. sub run {
  31. my ($self) = @_;
  32. # Do something
  33. }
  34.  
  35.  
  36. =pod
  37.  
  38. =head1 NAME
  39.  
  40. MyApp::SomeCommand - Some description
  41.  
  42. =head1 DESCRIPTION
  43.  
  44. A longer description
  45.  
  46. =cut
  47.  
  48.  
  49. ### And then in some simple wrapper script:
  50. #!/usr/bin/env perl
  51. use MyApp;
  52. MyApp->new_with_command->run;
Add Comment
Please, Sign In to add comment