packages feed

slate 0.5.0.0 → 0.6.0.0

raw patch · 3 files changed

+56/−5 lines, 3 filesdep +htomldep +processdep +string-conversionsPVP ok

version bump matches the API change (PVP)

Dependencies added: htoml, process, string-conversions, unordered-containers

API changes (from Hackage documentation)

Files

README.md view
@@ -1,6 +1,6 @@ # slate - a note taking tool. -A simple tool to take notes from your terminal.+A simple tool to take notes from your terminal (and sync them between your devices).  Generates markdown [task lists](https://help.github.com/articles/about-task-lists/). @@ -12,7 +12,7 @@ $ stack install slate ``` -## Usage+## Basic usage  <pre> $ slate --help@@ -35,6 +35,7 @@   display                  Display a slate.   rename                   Rename a slate.   wipe                     Wipe a slate.+  sync                     Sync every slate.  $ slate add "My *first* note." $ slate add "New note!"@@ -69,3 +70,13 @@ $ slate display 00 - My <b>first</b> note. </pre>++## The `sync` command++You can use `slate sync` to synchronize your slates. There's no default configuration for this command, you'll have to create the file `~/.config/slate/config.toml` and add your sync command, for example:++```toml+sync = "git add . && git commit -m 'Update slates'; git pull --rebase origin master && git push origin master"+```++This would stage & commit every updates in `~/.config/slate/`, update your local copy and push your updates to the `origin` remote.
slate.cabal view
@@ -2,10 +2,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: a81225f08162330e47d2508662b80ad4173c5197ba2b1bd34285bd1bba0d1cad+-- hash: e87869f3ba6c0eeba97ff6dac9093244bf62e025a4d08405ca7bacadca82a856  name:           slate-version:        0.5.0.0+version:        0.6.0.0 synopsis:       A note taking CLI tool. description:    Please see the README on Github at <https://github.com/evuez/slate#readme> homepage:       https://github.com/evuez/slate#readme@@ -33,7 +33,11 @@       base >=4.7 && <5     , directory >=1.3     , filepath >=1.4+    , htoml >=1.0     , optparse-applicative >=0.14+    , process >=1.6+    , string-conversions >=0.2+    , unordered-containers >=0.2   exposed-modules:       AnsiStyle       Lib@@ -50,8 +54,12 @@       base >=4.7 && <5     , directory >=1.3     , filepath >=1.4+    , htoml >=1.0     , optparse-applicative >=0.14+    , process >=1.6     , slate+    , string-conversions >=0.2+    , unordered-containers >=0.2   other-modules:       Paths_slate   default-language: Haskell2010@@ -66,8 +74,12 @@       base >=4.7 && <5     , directory >=1.3     , filepath >=1.4+    , htoml >=1.0     , optparse-applicative >=0.14+    , process >=1.6     , slate+    , string-conversions >=0.2+    , unordered-containers >=0.2   other-modules:       Paths_slate   default-language: Haskell2010
src/Lib.hs view
@@ -5,7 +5,10 @@   ) where  import AnsiStyle (toAnsi)+import qualified Data.HashMap.Lazy as M (lookup) import Data.Semigroup ((<>))+import Data.String (fromString)+import Data.String.Conversions (convertString) import Options.Applicative import System.Directory   ( createDirectoryIfMissing@@ -15,6 +18,9 @@   , renameFile   ) import System.FilePath.Posix (takeBaseName)+import System.Process (createProcess, cwd, shell, waitForProcess)+import Text.Toml (parseTomlDoc)+import Text.Toml.Types (Node(VString))  type Slate = String @@ -41,6 +47,7 @@            Slate   | Wipe Slate          Filter+  | Sync   deriving (Eq, Show)  -- Parsers@@ -83,6 +90,9 @@     str     (long "only" <> short 'o' <> help "Wipe only done / todo notes." <> value "") +sync :: Command+sync = Sync+ parser :: Parser Command parser =   subparser@@ -102,7 +112,8 @@      command "remove" (info remove (progDesc "Remove a note.")) <>      command "display" (info display (progDesc "Display a slate.")) <>      command "rename" (info rename (progDesc "Rename a slate.")) <>-     command "wipe" (info wipe (progDesc "Wipe a slate.")))+     command "wipe" (info wipe (progDesc "Wipe a slate.")) <>+     command "sync" (info (pure sync) (progDesc "Sync every slate.")))  -- Commands execute :: Command -> IO ()@@ -123,6 +134,7 @@ execute (Wipe "" f) = getSlateName >>= (\x -> execute (Wipe x f)) execute (Wipe s "") = getSlatePath s >>= removeFile execute (Wipe s f) = getSlatePath s >>= (\x -> wipeSlate x f)+execute (Sync) = syncSlates  -- Helpers initialize :: IO ()@@ -138,6 +150,11 @@   home <- getHomeDirectory   return $ home ++ "/.config/slate/" +getConfigFile :: IO String+getConfigFile = do+  dir <- getConfigDirectory+  return $ dir ++ "config.toml"+ getSlatePath :: String -> IO FilePath getSlatePath s = do   dir <- getConfigDirectory@@ -225,3 +242,14 @@   writeFile tmp $ unlines $ filter isNoteDone (lines contents)   renameFile tmp s wipeSlate _ f = putStr $ "\"" ++ f ++ "\" is not a valid filter."++syncSlates :: IO ()+syncSlates = do+  config <- (getConfigFile >>= readFile)+  dir <- getConfigDirectory+  let Right c = parseTomlDoc "" (fromString config)+  let Just (VString s) = M.lookup (fromString "sync") c+  (_, _, _, h) <-+    createProcess (shell (fromString $ convertString s)) {cwd = Just dir}+  _ <- waitForProcess h+  return ()