/pfg

Command line utility to quickly generate files from custom templates

Primary LanguagePythonMIT LicenseMIT

Python File Generator

Command line utility to quickly generate files from custom templates

Features

  • CLI operation
  • simple variable substitutions
  • include or exclude options sections
  • non-interactive operation with yaml file
  • save template substitutions as yaml file for future use to recreate that template
  • custom templates can be put in ~/.config/pfg/templates
  • config file that defines prefences and frequent variables like Author

Installation

Once v1.0 is released, this section will be populated..

  • pip from github
  • build from source (requires pyyaml)

Usage

usage: 	pfg [-t FILE] [-i FILE | --save_yaml] [-p] [-q | -v | -d] [outfile]
	pfg -c | --config
	pfg -h | --help
	pfg -V | --version

Generates a new file from a skeleton

positional arguments:
  outfile             name for output file

optional arguments:
  -h, --help          show this help message and exit
  -V, --version       display version number
  -t F, --template F  specify template file to use
  -p, --print         print output to console
  -i F, --in F        load yaml file to generate file non-interactively
  --save_yaml         save yaml dict for future use
  -q, --quiet         quiet output
  -v, --verbose       Verbose output
  -d, --debug         create debugging log
  --config            run app configuration tool

Once v1.0 is released, this section will be populated..

Default Templates

  • example template

Certain templates are shipped with the program by default, but additional templates I have made can be found in the pfg_templates dir. These can be modified (if desired) and added to ~/.config/pfg/templates.

Making custom templates

Any variable that is to be replaced is written %%My-Variable%% where My-Variable is the name of your variable.

Optional sections are indicated by placing ***My-Section*** and +++My-Section+++ on the lines before and after the section, respectively, where My-Section is the name of your section.

Using the pfgrc config file, specify common variables to automatically be substituted. There is also an option to always use the current day's date without asking.

Once v1.0 is released, this section will be populated..

Using non-interatice yaml files

Once v1.0 is released, this section will be populated..

Future Features

  • loop sections for defining repetitive things (command line options)
  • config file generator
  • template creation aid
  • template yaml header specifies the type of substitution: input or choice (right now just input)
  • ability to loop on section (for defining multiples of something repetitive)