slate 0.12.0.0 → 0.13.0.0
raw patch · 4 files changed
+95/−52 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Config: instance Config.GetConfig (GHC.Base.Maybe GHC.Base.String)
+ Ansi: Palette :: String -> String -> String -> String -> String -> Palette
+ Ansi: [primary] :: Palette -> String
+ Ansi: [secondary] :: Palette -> String
+ Ansi: [success] :: Palette -> String
+ Ansi: [ternary] :: Palette -> String
+ Ansi: [warning] :: Palette -> String
+ Ansi: data Palette
+ Ansi: instance GHC.Show.Show Ansi.Palette
+ Ansi: palette :: Palette
+ Config: instance Config.GetConfig (GHC.Maybe.Maybe GHC.Base.String)
- Command: Doing :: Slate -> (Maybe NoteId) -> Command
+ Command: Doing :: Slate -> Maybe NoteId -> Command
- Command: Done :: Slate -> (Maybe NoteId) -> Command
+ Command: Done :: Slate -> Maybe NoteId -> Command
- Command: Todo :: Slate -> (Maybe NoteId) -> Command
+ Command: Todo :: Slate -> Maybe NoteId -> Command
Files
- README.md +15/−14
- slate.cabal +19/−18
- src/Ansi.hs +20/−1
- src/Lib.hs +41/−19
README.md view
@@ -2,7 +2,7 @@ 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/). @@ -54,39 +54,40 @@ $ slate add "My *first* note." $ slate add "New note!" $ slate display-00 - My <b>first</b> note.-01 - New note!+0 - My <b>first</b> note.+1 - New note! $ slate done 0 $ slate display-<s>00 - My <b>first</b> note.</s>-01 - New note!+<s>0 - My <b>first</b> note.</s>+1 - New note! $ slate display --only=todo # or just slate todo-01 - New note!+1 - New note! $ slate status 1 done, 1 todo (2 total).-▮▮▮▮▮▮▮▮▮▮▮▮▮▮▯▯▯▯▯▯▯▯▯▯▯▯▯▯+50% · 1 done · 1 todo — sync ✔+▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▯▯▯▯▯▯▯▯▯▯▯▯▯▯▯ $ slate add "Fake note" $ slate display-<s>00 - My <b>first</b> note.</s>-01 - New note!-02 - Fake note+<s>0 - My <b>first</b> note.</s>+1 - New note!+2 - Fake note $ slate remove 2 $ slate display-<s>00 - My <b>first</b> note.</s>-01 - New note!+<s>0 - My <b>first</b> note.</s>+1 - New note! $ slate wipe --only=todo $ slate display-<s>00 - My <b>first</b> note.</s>+<s>0 - My <b>first</b> note.</s> $ slate todo 0 $ slate display-00 - My <b>first</b> note.+0 - My <b>first</b> note. </pre> Lists are stored in `~/.config/slate/` and their default name is the name of your current directory. You can use any other name you want using the `--name` option or by adding a `.slate` file containing the name you want to use.
slate.cabal view
@@ -1,11 +1,13 @@--- This file has been generated from package.yaml by hpack version 0.28.2.+cabal-version: 1.12++-- This file has been generated from package.yaml by hpack version 0.31.0. -- -- see: https://github.com/sol/hpack ----- hash: 1391bb62af66f9a2e775ecb379056cf77456c27fc59b7f928cb629cb9acb7806+-- hash: ca55e5d9e79e4ff7d881a04647a1111a94d04f291ee2995939812486f4807c72 name: slate-version: 0.12.0.0+version: 0.13.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@@ -16,16 +18,24 @@ license: MIT license-file: LICENSE build-type: Simple-cabal-version: >= 1.10 extra-source-files:- ChangeLog.md README.md+ ChangeLog.md source-repository head type: git location: https://github.com/evuez/slate library+ exposed-modules:+ Ansi+ Command+ Config+ Filter+ Lib+ Style+ other-modules:+ Paths_slate hs-source-dirs: src build-depends:@@ -37,19 +47,12 @@ , process >=1.6 , string-conversions >=0.2 , unordered-containers >=0.2- exposed-modules:- Ansi- Command- Config- Filter- Lib- Style- other-modules:- Paths_slate default-language: Haskell2010 executable slate main-is: Main.hs+ other-modules:+ Paths_slate hs-source-dirs: app ghc-options: -threaded -rtsopts -with-rtsopts=-N@@ -63,13 +66,13 @@ , slate , string-conversions >=0.2 , unordered-containers >=0.2- other-modules:- Paths_slate default-language: Haskell2010 test-suite slate-test type: exitcode-stdio-1.0 main-is: Spec.hs+ other-modules:+ Paths_slate hs-source-dirs: test ghc-options: -threaded -rtsopts -with-rtsopts=-N@@ -83,6 +86,4 @@ , slate , string-conversions >=0.2 , unordered-containers >=0.2- other-modules:- Paths_slate default-language: Haskell2010
src/Ansi.hs view
@@ -3,7 +3,9 @@ progress :: Double -> Int -> String progress percent size = makeInverse- ((replicate sizeCompleted ' ') ++ makeGrey (replicate sizeRemaining ' '))+ ((primary palette) +++ (replicate sizeCompleted ' ') +++ (secondary palette) ++ (replicate sizeRemaining ' ')) where size' = fromIntegral size :: Double sizeCompleted = round $ size' * percent / 100@@ -38,6 +40,23 @@ grey :: String grey = "\x1B[2;37m"++data Palette = Palette+ { primary :: String+ , secondary :: String+ , ternary :: String+ , success :: String+ , warning :: String+ } deriving (Show)++palette :: Palette+palette =+ Palette+ "\x1B[38;5;97m"+ "\x1B[38;5;74m"+ "\x1B[38;5;178m"+ "\x1B[38;5;72m"+ "\x1B[38;5;167m" makeBold :: String -> String makeBold s = bold ++ s ++ reset
src/Lib.hs view
@@ -4,7 +4,16 @@ , parser ) where -import Ansi (makeCrossed, makeGreen, makeInverse, makeRed, progress)+import Ansi+ ( Palette(primary, secondary, success, ternary, warning)+ , makeCrossed+ , makeGreen+ , makeInverse+ , makeRed+ , palette+ , progress+ , reset+ ) import Command (Command(..), parser) import Config (configDirectory, getConfigValue, getSlatePath) import qualified Filter as F (doing, done, todo)@@ -61,13 +70,17 @@ displayNote :: Int -> Int -> String -> String displayNote total line (' ':'-':' ':'[':_:']':' ':'>':note) =- makeInverse $ alignRight total line ++ " -" ++ preen note+ makeInverse $+ (ternary palette) ++ alignRight total line ++ reset ++ " -" ++ preen note displayNote total line (' ':'-':' ':'[':' ':']':note) =- alignRight total line ++ " -" ++ preen note+ (ternary palette) ++ alignRight total line ++ reset ++ " -" ++ preen note displayNote total line (' ':'-':' ':'[':'x':']':note) =- makeCrossed $ alignRight total line ++ " -" ++ preen note+ makeCrossed $+ (ternary palette) ++ alignRight total line ++ reset ++ " -" ++ preen note displayNote total line _ =- makeRed $ alignRight total line ++ " - Parsing error: line is malformed"+ makeRed $+ (ternary palette) +++ alignRight total line ++ reset ++ " - Parsing error: line is malformed" alignRight :: Int -> Int -> String alignRight x n = replicate (length (show x) - length (show n)) ' ' ++ show n@@ -146,23 +159,32 @@ displayStatus :: FilePath -> IO () displayStatus s = do- ss <- getSyncStatus s+ (syncColor, syncString) <- getSyncStatus s contents <- readFile s let done = fromIntegral $ length $ filter F.done (lines contents) :: Double todo = fromIntegral $ length $ filter F.todo (lines contents) :: Double percent = done / (done + todo) * 100 stats =- mconcat- [ show (round done :: Integer)- , " done, "- , show (round todo :: Integer)- , " todo ("- , show (round percent :: Integer)- , "% done)."- ]- putStrLn $ mconcat [stats, "\n", progress percent (length stats), "\n", ss]+ [ (ternary palette)+ , show (round percent :: Integer)+ , "% · "+ , reset+ , (primary palette)+ , show (round done :: Integer)+ , reset+ , " done · "+ , (secondary palette)+ , show (round todo :: Integer)+ , reset+ , " todo — "+ , syncColor+ , syncString+ , reset+ ]+ statsLength = sum [length (x : xs) | x:xs <- stats, x /= '\ESC']+ putStrLn $ mconcat [mconcat stats, "\n", progress percent statsLength] -getSyncStatus :: FilePath -> IO String+getSyncStatus :: FilePath -> IO (String, String) getSyncStatus s = do v <- getConfigValue ("callbacks", "status") case v of@@ -175,9 +197,9 @@ e <- waitForProcess h return $ case e of- ExitSuccess -> makeGreen "Synced ☺️"- (ExitFailure _) -> makeRed "Out of sync 😕"- Nothing -> return ""+ ExitSuccess -> ((success palette), "sync ✔")+ (ExitFailure _) -> ((warning palette), "sync ✘")+ Nothing -> return ("", "") syncSlates :: IO () syncSlates = do