App::Sqitch::ItemFormatter - Format events and changes for command output
my $formatter = App::Sqitch::ItemFormatter->new(%params); say $formatter->format($format, $item);
This class is used by commands to format items for output. For example, log uses it to format the events it finds. It uses String::Formatter to do the actual formatting, but configures it for all the various times of things typically displayed, such as change names, IDs, event types, etc. This keeps things relatively simple, as all one needs to pass to format() is a format and then a hash reference of values to be used in the format.
log
format()
new
my $formatter = App::Sqitch::ItemFormatter->new(%params);
Constructs and returns a formatter object. The supported parameters are:
abbrev
Instead of showing the full 40-byte hexadecimal change ID, format as a partial prefix the specified number of characters long.
date_format
Format to use for timestamps. Defaults to iso. Allowed values:
iso
iso8601
ISO-8601 format.
rfc
rfc2822
RFC-2822 format.
full
long
medium
short
A format length to pass to the system locale's LC_TIME category.
LC_TIME
raw
Raw format, which is strict ISO-8601 in the UTC time zone.
strftime:$string
An arbitrary strftime pattern. See "strftime Paterns" in DateTime for comprehensive documentation of supported patterns.
strftime
cldr:$pattern
An arbitrary cldr pattern. See "CLDR Paterns" in DateTime for comprehensive documentation of supported patterns.
cldr
color
Controls the use of ANSI color formatting. The value may be one of:
auto
always
never
formatter
A String::Formatter object. You probably don't want to pass one of these, as the default one understands all the values to that Sqitch is likely to want to format.
format
$formatter->format( $format, $item );
Formats an item as a string and returns it. The item will be formatted using the first argument. See "Formats" for the gory details.
The second argument is a hash reference defining the item to be formatted. These are simple key/value pairs, generally identifying attribute names and values. The supported keys are:
event
The type of event, which is one of:
deploy
revert
fail
project
The name of the project with which the change is associated.
change_id
The change ID.
change
The name of the change.
note
A brief description of the change.
tags
An array reference of the names of associated tags.
requires
An array reference of the names of any changes required by the change.
conflicts
An array reference of the names of any changes that conflict with the change.
committed_at
An App::Sqitch::DateTime object representing the date and time at which the event was logged.
committer_name
Name of the user who deployed the change.
committer_email
Email address of the user who deployed the change.
planned_at
An App::Sqitch::DateTime object representing the date and time at which the change was added to the plan.
planner_name
Name of the user who added the change to the plan.
planner_email
Email address of the user who added the change to the plan.
The format argument to format() specifies the item information to be included in the resulting string. It works a little bit like printf format and a little like Git log format. For example, this format:
printf
format:The committer of %h was %{name}c%vThe title was >>%s<<%v
Would show something like this:
The committer of f26a3s was Tom Lane The title was >>We really need to get this right.<<
The placeholders are:
%H: Event change ID
%H
%h: Event change ID (respects --abbrev)
%h
--abbrev
%n: Event change name
%n
%o: Event change project name
%o
%($len)h: abbreviated change of length $len
%($len)h
$len
%e: Event type (deploy, revert, fail)
%e
%l: Localized lowercase event type label
%l
%L: Localized title case event type label
%L
%c: Event committer name and email address
%c
%{name}c: Event committer name
%{name}c
%{email}c: Event committer email address
%{email}c
%{date}c: commit date (respects --date-format)
%{date}c
--date-format
%{date:rfc}c: commit date, RFC2822 format
%{date:rfc}c
%{date:iso}c: commit date, ISO-8601 format
%{date:iso}c
%{date:full}c: commit date, full format
%{date:full}c
%{date:long}c: commit date, long format
%{date:long}c
%{date:medium}c: commit date, medium format
%{date:medium}c
%{date:short}c: commit date, short format
%{date:short}c
%{date:cldr:$pattern}c: commit date, formatted with custom CLDR pattern
%{date:cldr:$pattern}c
%{date:strftime:$pattern}c: commit date, formatted with custom strftime pattern
%{date:strftime:$pattern}c
%c: Change planner name and email address
%{name}p: Change planner name
%{name}p
%{email}p: Change planner email address
%{email}p
%{date}p: plan date (respects --date-format)
%{date}p
%{date:rfc}p: plan date, RFC2822 format
%{date:rfc}p
%{date:iso}p: plan date, ISO-8601 format
%{date:iso}p
%{date:full}p: plan date, full format
%{date:full}p
%{date:long}p: plan date, long format
%{date:long}p
%{date:medium}p: plan date, medium format
%{date:medium}p
%{date:short}p: plan date, short format
%{date:short}p
%{date:cldr:$pattern}p: plan date, formatted with custom CLDR pattern
%{date:cldr:$pattern}p
%{date:strftime:$pattern}p: plan date, formatted with custom strftime pattern
%{date:strftime:$pattern}p
%t: Comma-delimited list of tags
%t
%{$sep}t: list of tags delimited by $sep
%{$sep}t
$sep
%T: Parenthesized list of comma-delimited tags
%T
%{$sep}T: Parenthesized list of tags delimited by $sep
%{$sep}T
%s: Subject (a.k.a. title line)
%s
%r: Comma-delimited list of required changes
%r
%{$sep}r: list of required changes delimited by $sep
%{$sep}r
%R: Localized label and list of comma-delimited required changes
%R
%{$sep}R: Localized label and list of required changes delimited by $sep
%{$sep}R
%x: Comma-delimited list of conflicting changes
%x
%{$sep}x: list of conflicting changes delimited by $sep
%{$sep}x
%X: Localized label and list of comma-delimited conflicting changes
%X
%{$sep}X: Localized label and list of conflicting changes delimited by $sep
%{$sep}X
%b: Body
%b
%B: Raw body (unwrapped subject and body)
%B
%{$prefix}B: Raw body with $prefix prefixed to every line
%{$prefix}
$prefix
%{event}_ Localized label for "event"
%{event}_
%{change}_ Localized label for "change"
%{change}_
%{committer}_ Localized label for "committer"
%{committer}_
%{planner}_ Localized label for "planner"
%{planner}_
%{by}_ Localized label for "by"
%{by}_
%{date}_ Localized label for "date"
%{date}_
%{committed}_ Localized label for "committed"
%{committed}_
%{planned}_ Localized label for "planned"
%{planned}_
%{name}_ Localized label for "name"
%{name}_
%{project}_ Localized label for "project"
%{project}_
%{email}_ Localized label for "email"
%{email}_
%{requires}_ Localized label for "requires"
%{requires}_
%{conflicts}_ Localized label for "conflicts"
%{conflicts}_
%v vertical space (newline)
%v
%{$color}C: An ANSI color: black, red, green, yellow, reset, etc.
%{$color}C
%{:event}C: An ANSI color based on event type (green deploy, blue revert, red fail)
%{:event}C
%{$attribute}a: The raw attribute name and value, if it exists and has a value
%{$attribute}a
Documentation for the log command to the Sqitch command-line client.
The Sqitch command-line client.
David E. Wheeler <david@justatheory.com>
Copyright (c) 2012-2014 iovation Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
To install App::Sqitch, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::Sqitch
CPAN shell
perl -MCPAN -e shell install App::Sqitch
For more information on module installation, please visit the detailed CPAN module installation guide.