Skip to content

Commit

Permalink
Style
Browse files Browse the repository at this point in the history
  • Loading branch information
cblp committed Mar 7, 2020
1 parent 228456a commit 917823c
Showing 1 changed file with 41 additions and 24 deletions.
65 changes: 41 additions & 24 deletions ff-core/lib/FF/CLI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,15 @@ runCmdConfig cfg@Config {dataDir, externalEditor, ui} = \case
guard =<< doesDirectoryExist baseDir
saveDataDir $ baseDir </> "Apps" </> appName
saveDataDir dir = saveConfig cfg {dataDir = Just dir} $> Just dir
saveExternalEditor path = saveConfig cfg {externalEditor = Just path} $> Just path
saveExternalEditor path =
saveConfig cfg {externalEditor = Just path} $> Just path
saveShuffle shuffle' = saveConfig cfg {ui = ui'} $> ui'
where
ui' = ConfigUI {shuffle = shuffle'}

runCmdAction
:: (MonadIO m, MonadStorage m) => ConfigUI -> CmdAction -> Bool -> Maybe FilePath -> m ()
runCmdAction ::
(MonadIO m, MonadStorage m) =>
ConfigUI -> CmdAction -> Bool -> Maybe FilePath -> m ()
runCmdAction ui cmd isBrief path = do
today <- getUtcToday
case cmd of
Expand All @@ -175,38 +177,48 @@ runCmdAction ui cmd isBrief path = do
for_ notes $ \noteId -> do
note <- cmdDeleteNote noteId
noteview <- viewNote note
pprint $ withHeader "Deleted:" (prettyNote isBrief noteview) <//> prettyPath path
pprint $
withHeader "Deleted:" (prettyNote isBrief noteview)
<//> prettyPath path
CmdDone notes ->
for_ notes $ \noteId -> do
note <- cmdDone noteId
noteview <- viewNote note
pprint $ withHeader "Archived:" (prettyNote isBrief noteview) <//> prettyPath path
pprint $
withHeader "Archived:" (prettyNote isBrief noteview)
<//> prettyPath path
CmdEdit edit -> do
notes <- cmdEdit edit
notes' <- traverse viewNote notes
pprint $ withHeader "Edited:" (prettyNoteList isBrief notes') <//> prettyPath path
pprint $
withHeader "Edited:" (prettyNoteList isBrief notes')
<//> prettyPath path
CmdNew new -> do
note <- cmdNewNote new today
noteview <- viewNote note
pprint $ withHeader "Added:" (prettyNote isBrief noteview) <//> prettyPath path
pprint $
withHeader "Added:" (prettyNote isBrief noteview) <//> prettyPath path
CmdPostpone notes ->
for_ notes $ \noteId -> do
note <- cmdPostpone noteId
noteview <- viewNote note
pprint $ withHeader "Postponed:" (prettyNote isBrief noteview) <//> prettyPath path
pprint $
withHeader "Postponed:" (prettyNote isBrief noteview)
<//> prettyPath path
CmdSearch Search {..} -> do
(tasks, wikis, contacts) <- cmdSearch text status ui limit today tags withoutTags
pprint
$ prettyTasksWikisContacts
isBrief
tasks
wikis
contacts
inTasks
inWikis
inContacts
tags
<//> prettyPath path
(tasks, wikis, contacts) <-
cmdSearch text status ui limit today tags withoutTags
pprint $
prettyTasksWikisContacts
isBrief
tasks
wikis
contacts
inTasks
inWikis
inContacts
tags
<//> prettyPath path
CmdShow noteIds -> do
notes <- for noteIds loadNote
notes' <- traverse viewNote notes
Expand All @@ -221,7 +233,9 @@ runCmdAction ui cmd isBrief path = do
for_ tasks $ \taskId -> do
task <- cmdUnarchive taskId
noteview <- viewNote task
pprint $ withHeader "Unarchived:" (prettyNote isBrief noteview) <//> prettyPath path
pprint $
withHeader "Unarchived:" (prettyNote isBrief noteview)
<//> prettyPath path
CmdUpgrade -> do
upgradeDatabase
liftIO $ putStrLn "Upgraded"
Expand Down Expand Up @@ -258,14 +272,17 @@ cmdTrack Track {dryRun, address, limit} today isBrief
exitFailure
Right issues -> pure issues

cmdContact :: (MonadIO m, MonadStorage m) => Bool -> Maybe FilePath -> Maybe Contact -> m ()
cmdContact ::
(MonadIO m, MonadStorage m) => Bool -> Maybe FilePath -> Maybe Contact -> m ()
cmdContact isBrief path= \case
Just (Add name) -> do
contact <- cmdNewContact name
pprint $ withHeader "Added:" (prettyContact isBrief contact) <//> prettyPath path
pprint $
withHeader "Added:" (prettyContact isBrief contact) <//> prettyPath path
Just (Delete cid) -> do
contact <- cmdDeleteContact cid
pprint $ withHeader "Deleted:" (prettyContact isBrief contact) <//> prettyPath path
pprint $
withHeader "Deleted:" (prettyContact isBrief contact) <//> prettyPath path
Nothing -> do
contacts <- getContactSamples Active
pprint $ prettyContactSample isBrief contacts <//> prettyPath path
Expand Down

0 comments on commit 917823c

Please sign in to comment.