App::Sqitch::ItemFormatter(3pm) User Contributed Perl Documentation App::Sqitch::ItemFormatter(3pm)

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.

"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.
"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.
"cldr:$pattern"
An arbitrary "cldr" pattern. See "CLDR Paterns" in DateTime for comprehensive documentation of supported patterns.
"color"
Controls the use of ANSI color formatting. The value may be one of:
"auto" (the default)
"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:

  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:

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-2024 iovation Inc., David E. Wheeler

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.

2024-02-08 perl v5.38.2