packages feed

jot (empty) → 0.1.0.0

raw patch · 6 files changed

+116/−0 lines, 6 filesdep +basedep +data-defaultdep +dhallsetup-changed

Dependencies added: base, data-default, dhall, docopt, extra, filepath, process, time, turtle, yaml

Files

+ ChangeLog.md view
@@ -0,0 +1,5 @@+# Changelog for Jot++## v0.1.0++Basic application creating markdown files with date and timestamps.
+ LICENSE view
@@ -0,0 +1,5 @@+Copyright 2018 Daniel Firth++Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.++THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ README.md view
@@ -0,0 +1,13 @@+# Jot++Jot is a little notebook. It makes little notepages with timestamps that you can customize. By default it uses vim and+puts stuff in notes/year/month/day.md. Try it with++    stack install+    jot++You can customize the configuration in configs/config.dhall and run.++    jot --config=configs/config.dhall++You can use either dhall or yaml for the config.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ app/Main.hs view
@@ -0,0 +1,46 @@+{-# LANGUAGE QuasiQuotes #-}++module Main where++import Control.Monad         ((>=>), (<=<), liftM2, when)+import Control.Monad.Extra   (unlessM)+import Data.Default          (def, Default)+import Data.Time             (defaultTimeLocale, formatTime, getCurrentTime, toGregorian, UTCTime(..))+import Data.Yaml             (decodeFileEither, FromJSON, ToJSON)+import Dhall                 (auto, input, Generic, Interpret)+import System.Console.Docopt (argument, command, docoptFile, getArg, getArgOrExitWith,+                              isPresent, longOption, parseArgsOrExit, Docopt)+import System.Environment    (getArgs)+import System.FilePath       ((</>), (<.>))+import System.Process        (callProcess)+import Turtle                (append, decodeString, fromString, liftIO, lstree, mktree, sh, testfile)++patterns :: Docopt+patterns = [docoptFile|USAGE.txt|]++getArgOrExit = getArgOrExitWith patterns++data Config = Config { dayFormat :: String, editor :: FilePath, editorOptions :: [String], logBook :: FilePath, timeFormat :: String }+  deriving (Eq, Show, Generic, Interpret, FromJSON, ToJSON)++instance Default Config where+  def = Config "%A %d %B" "vim" ["+"] "notes" "%H:%M"++decodeYamlOrDhall = liftM2 (>>=) decodeFileEither $ flip either return . const . (input auto . fromString <=< readFile)++dayToPreamble f d = "# " ++ formatTime defaultTimeLocale f d++timeToSubheader f t = "## " ++ formatTime defaultTimeLocale f t++main = do+  args <- parseArgsOrExit patterns =<< getArgs+  let cfile = getArg args (longOption "config")+  Config df ed edopts lb tf <- maybe (return def) decodeYamlOrDhall cfile :: IO Config+  dt@(UTCTime day time) <- getCurrentTime+  let (y, m, d) = toGregorian day+  let dir = lb </> (show y) </> (show m)+  let file = dir </> (show d) <.> "md"+  mktree $ decodeString dir+  unlessM (testfile $ decodeString file) $ appendFile file $ dayToPreamble df dt ++ "\n\n"+  appendFile file $ timeToSubheader tf dt ++ "\n\n"+  callProcess ed $ edopts ++ [file]
+ jot.cabal view
@@ -0,0 +1,45 @@+-- This file has been generated from package.yaml by hpack version 0.21.2.+--+-- see: https://github.com/sol/hpack+--+-- hash: d8ceea693aae4f57c2e508e7aa119309985fb4d40923b3f013e7c07d0bbd9c2d++name:           jot+version:        0.1.0.0+synopsis:       Tiny markdown notebook+description:    Jot is a little notebook. It makes little notepages with timestamps that you can customize.+category:       CLI+homepage:       http://gitlab.com/locallycompact/jot+author:         Daniel Firth+maintainer:     locallycompact@gmail.com+copyright:      2018 Daniel Firth+license:        ISC+license-file:   LICENSE+build-type:     Simple+cabal-version:  >= 1.10++extra-source-files:+    ChangeLog.md+    LICENSE+    README.md++executable jot+  main-is: Main.hs+  other-modules:+      Paths_jot+  hs-source-dirs:+      app+  default-extensions: ConstraintKinds DataKinds DeriveAnyClass DeriveFoldable DeriveFunctor DeriveGeneric DeriveTraversable FlexibleInstances FlexibleContexts GADTs GeneralizedNewtypeDeriving LambdaCase NoMonomorphismRestriction OverloadedStrings TypeFamilies+  ghc-options: -threaded -rtsopts -with-rtsopts=-N+  build-depends:+      base >=4.7 && <5+    , data-default+    , dhall+    , docopt+    , extra+    , filepath+    , process+    , time+    , turtle+    , yaml+  default-language: Haskell2010