project-forge-0.3.0.0: A project initialization library
Safe HaskellSafe-Inferred
LanguageHaskell2010

ProjectForge.Get

Description

Functions for marshalling Project and File Templates into a program.

Synopsis

Get Templates

Utilities for converting a directory into a ProjectTemplate.

getProjectTemplateFromDir Source #

Arguments

:: (MonadLogger m, MonadIO m) 
=> FilePath

name of the directory containing template files

-> m ProjectTemplate 

Convert a directory to a ProjectTemplate. A GetProjectTemplateError exception is thrown if the input directory does not exist.

>>> runSimpleLoggingT $ getProjectTemplateFromDir "foo"
NotADirectory

getProjectTemplateFromGit Source #

Arguments

:: (MonadLogger m, MonadIO m) 
=> Maybe FilePath

Optional parent directory in which to clone the repo in. Defaults to current directory.

-> GitURL

The Git URL of the template directory.

-> Maybe Branch

Optional name of git branch. If Nothing, uses default git branch.

-> m ProjectTemplate 

Convert a git repository to a ProjectTemplate.

This action creates a shallow clone of the repo in a temporary directory before calling getProjectTemplateFromDir on the temporary directory. The temporary directory is removed when complete.

This function requires that git be installed.

getFileTemplateFromFile Source #

Arguments

:: (MonadLogger m, MonadIO m) 
=> FilePath

name of the file

-> m FileTemplate 

Convert a file to a FileTemplate. A GetProjectTemplateError exception is thrown if the input file does not exist.

>>> runSimpleLoggingT $ getFileTemplateFromFile "foo.txt"
FileNotFound

directoryListToTemplate Source #

Arguments

:: MonadIO m 
=> [(FilePath, ByteString)]

list of (FilePath, ByteString) pairs corresponding to the contents of a template directory

-> m ProjectTemplate 

Converts a list of FilePath and ByteString pairs to a ProjectTemplate.

The ByteString are decoded into Text by decodeUtf8. If decoding results in a Data.Text.Encoding.Error.UnicodeException for any value, then this is thrown as an exception.