<commit_before>-- This is intended to a very quick script being the simplest thing
-- that could possibly work

import App.Clk.Util
import Data.List
import Data.Time
import Data.Time.Clock
import Data.Time.Calendar
import System.Environment

main = do
    -- display an entry line
    now <- getCurrentTime
    (tags,msg) <- fmap parseArgs getArgs
    let line = entryLine "<EMAIL>" now tags msg
    putStrLn line

    -- save the entry to disk
    clkDir <- getClkDir
    let file = folder clkDir now
    appendFile file (line++"\n")

entryLine :: String -> UTCTime -> [String] -> String -> String
entryLine e t ts m = intercalate "\t" [e,ymd,tags,m]
    where tags = intercalate "," ts
          ymd  = strftime iso8601 t

folder :: String -> UTCTime -> String
folder clkDir t = intercalate "" [clkDir,"timeline/",file]
    where file = strftime "%Y-%m.txt" t

-- init :: String -> IO ()
-- rough equivalent of `mkdir -p ~/.clkq/timeline`

isTagWord :: String -> Bool
isTagWord ('.':_) = True
isTagWord _       = False

-- converts a list of arguments into a tags list and a message string
parseArgs :: [String] -> ([String],String)
parseArgs args = (tags, msg)
    where (tagWords,msgWords) = partition isTagWord args
          tags = map tail tagWords
          msg  = intercalate " " msgWords<commit_msg>Explicitly return from the `in` main function<commit_after>-- This is intended to a very quick script being the simplest thing
-- that could possibly work

import App.Clk.Util
import Data.List
import Data.Time
import Data.Time.Clock
import Data.Time.Calendar
import System.Environment

main = do
    -- display an entry line
    now <- getCurrentTime
    (tags,msg) <- fmap parseArgs getArgs
    let line = entryLine "<EMAIL>" now tags msg
    putStrLn line

    -- save the entry to disk
    clkDir <- getClkDir
    let file = folder clkDir now
    appendFile file (line++"\n")
    return ()

entryLine :: String -> UTCTime -> [String] -> String -> String
entryLine e t ts m = intercalate "\t" [e,ymd,tags,m]
    where tags = intercalate "," ts
          ymd  = strftime iso8601 t

folder :: String -> UTCTime -> String
folder clkDir t = intercalate "" [clkDir,"timeline/",file]
    where file = strftime "%Y-%m.txt" t

-- init :: String -> IO ()
-- rough equivalent of `mkdir -p ~/.clkq/timeline`

isTagWord :: String -> Bool
isTagWord ('.':_) = True
isTagWord _       = False

-- converts a list of arguments into a tags list and a message string
parseArgs :: [String] -> ([String],String)
parseArgs args = (tags, msg)
    where (tagWords,msgWords) = partition isTagWord args
          tags = map tail tagWords
          msg  = intercalate " " msgWords
{'fraction_non_alphanumeric': 0.1111111111111111, 'fraction_numerical': 0.003003003003003003, 'mean_word_length': 2.948148148148148, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5337627', 'n_tokens_mistral': 843, 'n_tokens_neox': 802, 'n_words': 304}