diff options
| author | Eugen Wissner <belka@caraus.de> | 2025-01-24 22:38:58 +0100 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2025-01-24 22:38:58 +0100 |
| commit | 3c430bca64c813a0a04cb98d5cd9a3d3fb70e1b0 (patch) | |
| tree | 2896d05540a33312ee2050ef1919a92085a13e01 /tea-cleaner/TeaCleaner/Options.hs | |
| parent | c8b05eedfc876a6ef09472b5e92ba0455ad0f8b1 (diff) | |
| download | kazbek-3c430bca64c813a0a04cb98d5cd9a3d3fb70e1b0.tar.gz | |
Add gitea spam user cleaning script
Diffstat (limited to 'tea-cleaner/TeaCleaner/Options.hs')
| -rw-r--r-- | tea-cleaner/TeaCleaner/Options.hs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tea-cleaner/TeaCleaner/Options.hs b/tea-cleaner/TeaCleaner/Options.hs new file mode 100644 index 0000000..7353f8f --- /dev/null +++ b/tea-cleaner/TeaCleaner/Options.hs @@ -0,0 +1,24 @@ +module TeaCleaner.Options + ( jsonOptions + ) where + +import qualified Data.Aeson.TH as Aeson +import Prelude hiding (id) +import Data.Char + +applyFirst :: (Char -> Char) -> String -> String +applyFirst _ [] = [] +applyFirst f [x] = [f x] +applyFirst f (x:xs) = f x: xs + +-- | Generic casing for symbol separated names +symbCase :: String -> String +symbCase = u . applyFirst toLower + where u [] = [] + u (x:xs) | isUpper x = '_' : toLower x : u xs + | otherwise = x : u xs + +jsonOptions :: Aeson.Options +jsonOptions = Aeson.defaultOptions + { Aeson.fieldLabelModifier = symbCase + } |
