Skip to content

reidmv/puppet-format

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

puppet-format

CI Puppet Forge Puppet Forge - downloads Puppet Forge - endorsement Puppet Forge - scores Apache-2 License

This module includes puppet functions to transform your boring, old and worn looking ascii characters into beautiful looking masterpieces.

Table of Contents

  1. Description
  2. Setup - The basics of getting started with format
  3. Usage - Configuration options and additional functionality
  4. Limitations - OS compatibility, etc.
  5. Development - Guide for contributing to the module

Description

With this module you can produce amazing looking tables, colorized strings and others transformations for output to the terminal screen. While this module is mainly for bolt plans it could be used in puppet code anywhere.

Setup

What format affects

This module includes functions and datatypes only.

Setup Requirements

Bolt and Puppet

Usage

This module only contains functions to format and transform data. It will not output anything to stdout and only return formatted data ready to be sent to stdout or stderr.

Functions

  • format::colorize("string", red) # options include red, green, yellow, fatal, warning, good.
  • format::table([['one', 1], ['two', 2]])

The print_table function wraps the Terminal-Table ruby gem in a function and tries to provide the same API. You can create a table in two ways.

  • by passing a TableRows type (Array of Arrays)
  • by passing a TerminalTable type (Hash of various keys)

Example:

# puppet code
format::table({title => 'GPU list', head => ['Name', 'QTY'],
               rows => [['GTX 1070', 5], ['GTX 2080 ti', 1]],
               style => {width => 60 }
            })

Which produces a table like:

+-----------------------------+----------------------------+
|                         GPU list                         |
+-----------------------------+----------------------------+
| Name                        | QTY                        |
+-----------------------------+----------------------------+
| GTX 1070                    | 5                          |
| GTX 2080 ti                 | 1                          |
+-----------------------------+----------------------------+

Or with colors

About

Text formatting functions for puppet lang

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 91.6%
  • Puppet 4.1%
  • Dockerfile 3.8%
  • Pascal 0.5%