Coder Social home page Coder Social logo

pric's Introduction

๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป Pric: Print Code

The goal of this tool is to provide an easy way to produce a PDF out of a set of code files.

โ„น Pric is slow, it takes some seconds to print the usage help and a bit longer to produce the PDF.

Usage

Given the following project, we can generate a PDF out of the Java files.

.
`-- src
    |-- META-INF
    |   `-- MANIFEST.MF
    `-- hercerm
        `-- iindices
            |-- app
            |   |-- ApplicationStarter.java
            |   `-- WordSearcherApplication.java
            |-- core
            |   |-- FileContentCleanser.java
            |   |-- IIValue.java
            |   |-- IIndexGenerator.java
            |   |-- REPL.java
            |   |-- REPLCommands.java
            |   |-- TXTCleanser.java
            |   `-- WordSearcher.java
            `-- util
                |-- FileDownloader.java
                |-- PathsAccessor.java
                `-- Serializer.java

To create the PDF, simply run:

pric output_file.pdf -re java

Which produces output_file.pdf, with a cover page, syntax highlighted code listings and a table of contents shown by the PDF reader:

Options

$ pric -h

Print multiple source code files to a single PDF file.

pric [OPTIONS] file

Parameters:
      file                Filename of the PDF, must end in '.pdf'.

Options:
  -a, --author=<author>   Author of the document.
  -c, --compact           Produce a PDF with more code per page and no cover
                            page.
  -e, --extensions=<ext>[,<ext>...]
                          Extensions of the files to be printed.
  -f, --files=<regex>[:<regex>...]
                          Match filenames by regex.
  -h, --help              Show this help message and exit.
  -k, --keep-asciidoc     Preserve AsciiDoc file after PDF generation.
  -p, --paths=<path>[?<path>...]
                          Absolute or relative paths to directories to search
                            for files (default is current dir)
  -r, --recursive         Recurse sub-directories.
  -s, --silent            Do not show log messages.
  -t, --title=<title>     Title of the document. If omitted, filename is used.
  -V, --version           Print version information and exit.

Exit codes:
  0    Successful PDF generation.
  1    No PDF was generated.

Examples:
Notice that the default title of every document is the provided filename
(in the examples below, the title of most documents is 'out'). To set an
appropriate title different from the filename, use the option -t, as shown
in the example 3.

1. Include all Java and XML files on the current dir and its sub-dirs.
pric out.pdf -r -e java,xml

2. Include all Markdown files and the LICENSE file found on the current
directory.
pric out.pdf -e md -f 'LICENSE'
Notice the single quotes around LICENSE. Always use single quotes around the
arg value of -f, to avoid the shell from evaluating the expression.

3. Include all SQL files in current dir and add cover page with title and
author.
pric out.pdf -e sql -a 'Hernan Cervera' -t 'Database design'

4. Include all SQL files in current dir and remove cover page from PDF.
pric out.pdf -e sql -c
  • By default, the PDF generated has one file per page. If you are dealing with many small files, this might not be ideal. The --compact option generates a PDF with no cover page, no ToC, and attempts to place more files per page.
  • If you would like to further customize the PDF, for example by adding a paragraph or some other information, you can use --keep-asciidoc to preserve the AsciiDoc file and manually edit it as you will. Then it is simple to generate your PDF by using asciidoctor-pdf.

Requirements

  • Groovy 3
  • Java 8

Installation

Linux

Download Pric and provide execution permission:

chmod +x pric

To have the script globally available, copy it to /usr/local/bin.

Windows

  1. Make sure you have a shell which supports Bash, e.g. Git Bash.
  2. Download Pric and you are done.
  3. (Optional but recommended) Make the script globally available by configuring your PATH environment variable.

pric's People

Contributors

hercerm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.