<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">NAME
====

CASCM::Wrapper - Run CA-SCM (Harvest) commands

    use CASCM::Wrapper;

    # Initialize
    my $cascm = CASCM::Wrapper-&gt;new();

    # Set Context
    $cascm-&gt;set_context(
        {    # Set a global context. This is applied to all commands where required
           global =&gt; { b  =&gt; 'harvest',
                       eh =&gt; 'user.dfo',
           },

           # Set 'hco' specific context, applied only to hco commands
           hco =&gt; { up =&gt; 1,
                    vp =&gt; '\repository\myapp\src',
                    pn =&gt; 'Checkout Items',
           },

           # Similarly for 'hci'
           hci =&gt; { vp =&gt; '\repository\myapp\src',
                    pn =&gt; 'Checkin Items',
                    de =&gt; 'Shiny new feature',
           },

           # And 'hcp'
           hcp =&gt; { st =&gt; 'development',
                    at =&gt; 'userid',
           },
        }
    ) or die $cascm-&gt;errstr;

    # Create Package
    my $pkg = 'new_package';
    $cascm-&gt;hcp($pkg) or die $cascm-&gt;errstr;

    # Checkout files
    my @files = qw(foo.c bar.c);
    $cascm-&gt;hco( { p =&gt; $pkg }, @files ) or die $cascm-&gt;errstr;

    # Update Context
    $cascm-&gt;update_context( { hci =&gt; { p =&gt; $pkg }, } ) or die $cascm-&gt;errstr;

    # Checkin files
    $cascm-&gt;hci(@files) or die $cascm-&gt;errstr;

DESCRIPTION
===========

This module is a wrapper around CA Software Change Manager's (formerly
known as Harvest) commands. It provides a perl-ish interface to setting
the context in which each command is executed, along with optional
loading of context from files as well as parsing output logs.

CONTEXT
=======

The context is a hash of hashes which contain the following types of
keys:

-   global

This specifies the global context. Any context set here will be applied
to every command that uses it.

    my $global_context = {
                           global =&gt; { b  =&gt; 'harvest',
                                       eh =&gt; 'user.dfo',
                           },
      };

-   command specific

This provides a command specific context. Context set here will be
applied only to those specific commands.

    my $hco_context = {
                        hco =&gt; { up =&gt; 1,
                                 vp =&gt; '\repository\myapp\src',
                                 pn =&gt; 'Checkout Items',
                        },
    };

The global and command context keys are synonymous with the command line
options detailed in the CA-SCM Reference Manual. Options that do not
require a value should be set to '1'. i.e. {hco =&gt; {up =&gt; 1} } is
equivalent to hco -up. The methods are intelligent enough to apply only
the context keys that are used by a command. For e.g. a global context
of vp will not apply to hcp.

The 'common' options i and di are not applicable and ignored for all
commands. See "SECURITY"

The following methods are available to manage context

set_context($context)
---------------------

Sets the context. Old context is forgotten. The argument provided must
be a hash reference

update_context($context)
------------------------

Updates the current context. The argument provided must be a hash
reference

load_context($file)
-------------------

This loads the context from an 'INI' file. The root parameters defines
the global context. Each sectional parameter defines the command
specific context. Old context is forgotten.

    # Load context file at initialization. This will croak if it fails to read the context file
    my $cascm = CASCM::Wrapper-&gt;new( { context_file =&gt; $file } );

    # Alternatively
    $cascm-&gt;load_context($file) or die $cascm-&gt;errstr;

This is a sample context file

    # Sample context file

    # Root parameters. These define the 'global' context
    b  = harvest
    eh = user.dfo

    # Sectional parameters. These define the 'command' context

    [hco]
        up = 1
        vp = \repository\myapp\src

    [hcp]
        st = development

NOTE: This method requires Config::Tiny in order to read the context
file.

get_context()
-------------

Returns a hash reference of current context

    my $context = $cascm-&gt;get_context();
    use Data::Dumper;
    print Dumper($context);

CA-SCM METHODS
==============

Almost every 'h' command that uses a context is supported. The command
names are synonymous with the methods used to invoke them.

Every method accepts two optional arguments. The first is an hash
reference that overrides/appends to the context for that method. This
allows setting a context only for that specific method call. The second
is an array of arguments that is passed on to the 'h' command. Any
arguments provided is passed using the '-arg' option.

    # No parameters. Everything required is already set in the context
    $cascm-&gt;hdlp() or die $cascm-&gt;errstr;

    # Array of arguments
    $cascm-&gt;hci( @files ) or die $cascm-&gt;errstr;

    # Override/Append to context
    $cascm-&gt;hci( { p =&gt; 'new_package' }, @files ) or die $cascm-&gt;errstr;

The methods can be called in a 'dry run' mode. Where the method returns
the full command line, without executing anything. This can be useful
for debugging.

    $cascm = CASCM::Wrapper-&gt;new( { dry_run =&gt; 1 } );
    $cascm-&gt;set_context($context);
    $cmd = $cascm-&gt;hsync();
    print "Calling hsync() would have executed -&gt; $cmd";

The following CA-SCM commands are available as methods

    hap
    har
    hci
    hco
    hcp
    hdp
    hdv
    hft
    hlr
    hlv
    hpg
    hpp
    hri
    hrt
    hsv
    hup
    hcbl
    hchu
    hcpj
    hdlp
    hspp
    hsql
    hudp
    hfatt
    hsmtp
    hsync
    hccmrg
    hdelss
    hexecp
    hmvitm
    hmvpkg
    hmvpth
    hrnitm
    hrnpth
    haccess
    hcrrlte
    hexpenv
    hgetusg
    himpenv
    hrmvpth
    hsigget
    hsigset
    htakess
    hucache
    husrmgr
    husrunlk
    hchgtype
    hcmpview
    hcropmrg
    hcrtpath
    hdbgctrl
    hpkgunlk
    hppolget
    hppolset
    hrefresh
    hrepedit
    hrepmngr
    hauthsync
    hformsync

SECURITY
========

This module uses the di option for executing CA-SCM commands. This
prevents any passwords from being exposed while the command is running.
The temporary di file is deleted irrespective if the outcome of the
command.

LOGGING
=======

Since CA-SCM commands output only to log files, this module allows
parsing and logging of a command's output. Log::Any is required to use
this feature, which in turn allows you to use any (supported) Logging
mechanism. When using this, any 'o' or 'oa' options specified in the
context will be ignored. Your scripts will need to load the appropriate
Log::Any::Adapter to capture the log statements. The CA-SCM log is
parsed and the messages are logged either as 'INFO', 'WARN' or 'ERROR'.

    # Using Log4perl

    use CASCM::Wrapper;
    use Log::Log4perl;
    use Log::Any::Adapter;

    Log::Log4perl-&gt;init('log4perl.conf');
    Log::Any::Adapter-&gt;set('Log4perl');

    # Get logger
    my $log = Log::Log4perl-&gt;get_logger();

    # Set parse_logs to true. This will croak if Log:Any is not found.
    my $cascm = CASCM::Wrapper-&gt;new( { parse_logs =&gt; 1 } );

    # Set Context
    my $context = { ... };
    $cascm-&gt;set_context($context);

    # Calling the method automatically will parse the log output into the Log4perl object
    # The output is also logged in the 'CASCM::Wrapper' category.

    $cascm-&gt;hco(@files) or die $cascm-&gt;errstr;

ERROR HANDLING
==============

All methods return true on success and undef on failure. The error that
most likely caused the last failure can be obtained by calling the
errstr method.

DEPENDENCIES
============

CA-SCM r12 (or higher) client. Harvest 7.1 might work, but has not been
tested.

The CA-SCM methods depends on the corresponding commands to be available
in the PATH

At least Perl 5.6.1 is required to run.

Optionally, Config::Tiny is required to read context files

Optionally, Log::Any and Log::Any::Adapter is required to parse CA-SCM
log files

SEE ALSO
========

CA Software Change Manager

BUGS AND LIMITATIONS
====================

Please report any bugs or feature requests to
bug-cascm-wrapper@rt.cpan.org, or through the web interface at
http://rt.cpan.org/Public/Dist/Display.html?Name=CASCM-Wrapper

AUTHOR
======

Mithun Ayachit mithun@cpan.org

LICENSE AND COPYRIGHT
=====================

Copyright (c) 2012, Mithun Ayachit. All rights reserved.

This module is free software; you can redistribute it and/or modify it
under the same terms as Perl itself. See perlartistic.
</pre></body></html>