headroom-0.3.2.0: License Header Manager
Copyright(c) 2019-2020 Vaclav Svejcar
LicenseBSD-3-Clause
Maintainervaclav.svejcar@gmail.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Headroom.Command.Run

Description

Module representing the run command, the core command of Headroom, which is responsible for license header management.

Synopsis

Documentation

commandRun Source #

Arguments

:: CommandRunOptions

Run command options

-> IO ()

execution result

Handler for Run command.

loadBuiltInTemplates Source #

Arguments

:: HasLogFunc env 
=> LicenseType

license type for which to selected templates

-> RIO env (Map FileType TemplateType)

map of file types and templates

Loads built-in templates, stored in Headroom.Embedded, for the given LicenseType.

loadTemplateFiles Source #

Arguments

:: (Has (FileSystem (RIO env)) env, HasLogFunc env) 
=> [FilePath]

paths to template files

-> RIO env (Map FileType TemplateType)

map of file types and templates

Loads templates from the given paths.

typeOfTemplate Source #

Arguments

:: HasLogFunc env 
=> FilePath

path to the template file

-> RIO env (Maybe FileType)

detected template type

Takes path to the template file and returns detected type of the template.

License Header Post-processing

postProcessHeader' Source #

Arguments

:: (Has CtHeaderFnConfigs env, Has CurrentYear env) 
=> HeaderSyntax

syntax of the license header comments

-> Variables

template variables

-> Text

rendered license header to post-process

-> RIO env Text

post-processed license header

Performs post-processing on rendered license header, based on given configuration. Currently the main points are to:

  1. sanitize possibly corrupted comment syntax (sanitizeHeader)
  2. apply license header functions (postProcessHeader)

sanitizeHeader Source #

Arguments

:: HeaderSyntax

syntax of the license header comments

-> Text

input text to sanitize

-> Text

sanitized text

Ensures that all lines in license header starts with line-comment syntax if such syntax is used for license header.

>>> sanitizeHeader (LineComment "--") "-- foo\nbar\n-- baz"
"-- foo\n-- bar\n-- baz"