Copyright | (c) 2019-2020 Vaclav Svejcar |
---|---|
License | BSD-3-Clause |
Maintainer | vaclav.svejcar@gmail.com |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
Module representing the run
command, the core command of Headroom, which is
responsible for license header management.
Synopsis
- commandRun :: CommandRunOptions -> IO ()
- loadBuiltInTemplates :: HasLogFunc env => LicenseType -> RIO env (Map FileType TemplateType)
- loadTemplateFiles :: (Has (FileSystem (RIO env)) env, HasLogFunc env) => [FilePath] -> RIO env (Map FileType TemplateType)
- typeOfTemplate :: HasLogFunc env => FilePath -> RIO env (Maybe FileType)
- postProcessHeader' :: (Has CtHeaderFnConfigs env, Has CurrentYear env) => HeaderSyntax -> Variables -> Text -> RIO env Text
- sanitizeHeader :: HeaderSyntax -> Text -> Text
Documentation
:: CommandRunOptions | Run command options |
-> IO () | execution result |
Handler for Run command.
:: 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
.
:: (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.
:: 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
:: (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:
- sanitize possibly corrupted comment syntax (
sanitizeHeader
) - apply license header functions (
postProcessHeader
)
:: 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"