PkgForge::Registry::App - A Moose role for applications which use the registry


This documentation refers to PkgForge::Registry::App version 1.3.0


      package PkgForge::App::Foo;

      use Moose;

      with 'PkgForge::Registry::App';

      sub action_add { ... }

      sub action_delete { ... }


      # and then via the command-line pkgforge application:

      % pkgforge foo add
      % pkgforge foo del


This is a Moose role which is designed to simplify the creation of Package Forge command-line applications that need to query or modify the registry. It is intended to assist in doing two separate things which are always required. The first is to add support for sub-commands (actions) on top of the MooseX::App::Cmd behaviour already in place. The second is to give standardised access to the Package Forge registry.


Any class which has this role applied will have the following attributes:


An optional configuration file name which can be used to set the values of the registry database attributes when a PkgForge::Registry object is instantiated using the new_with_config method. If not specified then the default file will be used, if it exists, see PkgForge::Registry for full details. When used in conjunction with MooseX::App::Cmd::Command this becomes available as a command-line option.


This holds the reference to the PkgForge::Registry object itself.


Any class which has this role applied will have the following methods:


This returns the list of all "action" methods in a class. An action method is just a normal method with the name prefixed by action_. The prefix is stripped from the method names, e.g. if there is a method named action_foo then this method will return foo.


This method takes the list of action methods from the actions_list method and converts it into a hash using Text::Abbrev. The keys are the unique abbreviations for each action name and the values are the full length name.


This method converts the list of actions into a comma-separated string suitable for displaying to the user.


Normally all attributes would be marked as required where necessary. When using this role some attributes may only be required for certain actions. This method can be used to check the requirements for each action. It is called to ensure that those attributes exist and have values set, if any are not set it will die with a useful error message.


The App::Cmd::Command class expects there to be a method named execute which does the actual work. This role extends this to allow sub-commands (actions) and this is the method which decides what action method should be executed. This allows the user to do something like:

        pkgforge foo list

        pkgforge foo add

        pkgforge foo del

by creating a class named PkgForge::App::Foo, which applies this role, with methods named action_list, action_add and action_delete.


This role adds an attribute, named configfile, which can be used to load a configuration file for the registry DB access. If you do not specify this file name then the PkgForge::Registry object will be created using the default configuration file, if it exists and is accessible. When used in conjunction with MooseX::App::Cmd::Command this becomes available as a command-line option.

It is not necessary to set all the attributes to successfully connect to the database. The DBI layer has support for using environment variables for nearly all possible connection options, see DBD::Pg for full details.


This module is powered by Moose and uses MooseX::ConfigFromFile and MooseX::Types. This module is intended to work with MooseX::App::Cmd::Command but there is no direct dependency. It also uses Text::Abbrev to handle unique shortened names for actions.


PkgForge, pkgforge(1)


This is the list of platforms on which we have tested this software. We expect this software to work on any Unix-like platform which is supported by Perl.

ScientificLinux5, Fedora13


Please report any bugs or problems (or praise!) to, feedback and patches are also always very welcome.


    Stephen Quinney <>


    Copyright (C) 2010 University of Edinburgh. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the terms of the GPL, version 2 or later.