---
name: "pgFormatter::CLI"
section: "3pm"
platform: "linux"
package: "pgformatter"
version: "5.11-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/pgFormatter::CLI"
---

# pgFormatter::CLI(3pm)

Implementation of command line program to format SQL queries.

## NAME

pgFormatter::CLI - Implementation of command line program to format SQL queries.

## VERSION

Version 5.11

## SYNOPSIS

This module is called by pg\_format program, when it detects it is not being run in CGI environment. In such case all control over flow is passed to this module by calling:

```
    my $program = pgFormatter::CLI->new();
    $program->run()
```

## FUNCTIONS

### new

Object constructor, nothing fancy in here.

### run

Wraps all work related to pg\_format CLI program. This includes calling methods to read command line parameters, validate them, read query, beautify it, and output.

### beautify

Actually formats loaded query using pgFormatter::Beautify library. If necessary runs anonymization.

### save\_output

Saves beautified query to whatever is output filehandle

### logmsg

Display message following the log level

### show\_help\_and\_die

As name suggests - shows help page, with optional error message, and ends program.

### load\_sql

Loads SQL from input file or stdin.

### get\_command\_line\_args

Parses command line options into `$self`-\>{'cfg'}.

### validate\_args

Validates that options parsed from command line have sensible values, opens input and output files.

## AUTHOR

pgFormatter is an original work from Gilles Darold

## BUGS

Please report any bugs or feature requests to: https://github.com/darold/pgFormatter/issues

## COPYRIGHT

Copyright 2012-2026 Gilles Darold. All rights reserved.

## LICENSE

pgFormatter is free software distributed under the PostgreSQL Licence.

A modified version of the SQL::Beautify Perl Module is embedded in pgFormatter with copyright (C) 2009 by Jonas Kramer and is published under the terms of the Artistic License 2.0.
