File perl-MooseX-App.spec of Package perl-MooseX-App

#
# spec file for package perl-MooseX-App
#
# Copyright (c) 2023 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%define cpan_name MooseX-App
Name:           perl-MooseX-App
Version:        1.43
Release:        0
License:        Artistic-1.0 OR GPL-1.0-or-later
Summary:        Write user-friendly command line apps with even less suffering
URL:            https://metacpan.org/release/%{cpan_name}
Source0:        https://cpan.metacpan.org/authors/id/M/MA/MAROS/%{cpan_name}-%{version}.tar.gz
BuildArch:      noarch
BuildRequires:  perl
BuildRequires:  perl-macros
BuildRequires:  perl(Config::Any)
BuildRequires:  perl(List::Util) >= 1.44
BuildRequires:  perl(Module::Pluggable)
BuildRequires:  perl(Moose) >= 2.00
BuildRequires:  perl(Pod::Elemental)
BuildRequires:  perl(Test::Most)
BuildRequires:  perl(Test::NoWarnings)
BuildRequires:  perl(namespace::autoclean)
Requires:       perl(Config::Any)
Requires:       perl(List::Util) >= 1.44
Requires:       perl(Module::Pluggable)
Requires:       perl(Moose) >= 2.00
Requires:       perl(Pod::Elemental)
Requires:       perl(namespace::autoclean)
%{perl_requires}

%description
MooseX-App is a highly customisable helper to write user-friendly command
line applications without having to worry about most of the annoying things
usually involved. Just take any existing Moose class, add a single line
('use MooseX-App qw(PluginA PluginB ...);') and create one class for each
command in an underlying namespace. Options and positional parameters can
be defined as simple Moose accessors using the 'option' and 'parameter'
keywords respectively.

MooseX-App will then

* * Find, load and initialise the command classes (see
  MooseX::App::Simple for single class/command applications)

* * Create automated help and documentation from modules POD as well as
  attributes metadata and type constraints

* * Read, encode and validate the command line options and positional
  parameters entered by the user from @ARGV and %ENV (and possibly prompt
  the user for additional parameters see MooseX::App::Plugin::Term)

* * Provide helpful error messages if user input cannot be validated
  (either missing or wrong attributes or Moose type constraints not
  satisfied)
  or if the user requests help.

Commandline options are defined using the 'option' keyword which accepts
the same attributes as Moose' 'has' keyword.

  option 'some_option' => (
      is            => 'rw',
      isa           => 'Str',
  );

This is equivalent to

  has 'some_option' => (
      is            => 'rw',
      isa           => 'Str',
      traits        => ['AppOption'],   # Load extra metaclass
      cmd_type      => 'option',        # Set attribute type
  );

Single letter options are treated as flags and may be combined with each
other. However such options must have a Boolean type constraint.

 option 'verbose' => (
      is            => 'rw',
      isa           => 'Bool',
      cmd_flag      => 'v',
  );

Positional parameters are defined with the 'parameter' keyword

  parameter 'some_option' => (
      is            => 'rw',
      isa           => 'Str',
  );

This is equivalent to

  has 'some_option' => (
      is            => 'rw',
      isa           => 'Str',
      traits        => ['AppOption'],
      cmd_type      => 'parameter',
  );

All keywords are imported by Moosex::App (in the app base class) and
MooseX::App::Command (in the command class) or MooseX::App::Simple (single
class application).

Furthermore, all options and parameters can also be supplied via %ENV

  option 'some_option' => (
      is            => 'rw',
      isa           => 'Str',
      cmd_env       => 'SOME_OPTION', # sets the env key
  );

Moose type constraints help MooseX::App to construct helpful error messages
and parse @ARGV in a meaningful way. The following type constraints are
supported:

* * ArrayRef: Specify multiple values ('--opt value1 --opt value2',
  also see app_permute and cmd_split)

* * HashRef: Specify multiple key value pairs ('--opt key=value --opt
  key2=value2', also see app_permute)

* * Enum: Display all possibilities

* * Bool: Flags that do not require values

* * Int, Num: Used for proper error messages

Read the Tutorial for getting started with a simple MooseX::App command
line application.

%prep
%autosetup  -n %{cpan_name}-%{version}

find . -type f ! -path "*/t/*" ! -name "*.pl" ! -path "*/bin/*" ! -path "*/script/*" ! -path "*/scripts/*" ! -name "configure" -print0 | xargs -0 chmod 644

%build
perl Makefile.PL INSTALLDIRS=vendor
%make_build

%check
make test

%install
%perl_make_install
%perl_process_packlist
%perl_gen_filelist

%files -f %{name}.files
%doc Changes README.md TODO
%license LICENSE

%changelog
openSUSE Build Service is sponsored by