Code Monkey home page Code Monkey logo

puppet-format's Introduction

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

This module requires the terminal-table gem. It's a direct dependency for bolt, so open source users don't need to install additional gems. For PE users that want to use the function, they need to install terminal-table for the orchestrator:

GEM_PATH=/opt/puppetlabs/server/apps/bolt-server/lib/ruby GEM_HOME=/opt/puppetlabs/server/apps/bolt-server/lib/ruby /opt/puppetlabs/puppet/bin/gem install terminal-table --no-document

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

puppet-format's People

Contributors

bastelfreak avatar ekohl avatar logicminds avatar maxadamo avatar reidmv avatar smortex avatar zilchms avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.