Skip to content

Commit

Permalink
Add support for filter expressions to sub-command new
Browse files Browse the repository at this point in the history
  • Loading branch information
ad-si committed Apr 10, 2024
1 parent 445b96e commit 9ab3992
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 87 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.stack-work
*.hie
/docs
/docs-source/images/pattern.jpg
26 changes: 14 additions & 12 deletions tasklite-core/source/Cli.hs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ data Command
-- \| Fork -- Create new SQLite db with the tasks of the specified query
| ListAll
| ListHead
| ListNew
| ListNewFiltered (Maybe [Text])
| ListOld
| ListOpen
| ListModified
Expand Down Expand Up @@ -382,7 +382,7 @@ aliasWarning alias =
<+> "Use"
<+> dquotes (pretty alias)
<+> "instead."
<> hardline
<> hardline


getCommand :: (Text, Text) -> Mod CommandFields Command
Expand Down Expand Up @@ -687,9 +687,11 @@ commandParser conf =
<> command "recurring" (toParserInfo (pure ListRecurring)
"List all recurring tasks by priority desc")

<> command "new" (toParserInfo (pure ListNew)
("List " <> numTasks
<> " newest open tasks by creation UTC desc"))
<> command "new"
(toParserInfo
(ListNewFiltered <$> optional (some
(strArgument $ metavar "FILTER_EXP" <> help "Filter expressions")))
"List newest tasks by creation UTC desc (Open and Closed)")

<> command "old" (toParserInfo (pure ListOld)
("List " <> numTasks
Expand Down Expand Up @@ -955,11 +957,11 @@ commandParserInfo conf =
header =
annotate (bold <> color Blue) "TaskLite"
<+> prettyVersion
<> hardline
<> hardline
<> annotate
(color Blue)
"Task-list manager powered by Haskell and SQLite"
<> hardline
<> hardline
<> annotate
(color Blue)
"Task-list manager powered by Haskell and SQLite"

examples = do
let
Expand Down Expand Up @@ -1137,7 +1139,7 @@ executeCLiCommand conf now connection progName args = do
case cliCommand of
ListAll -> listAll conf now connection
ListHead -> headTasks conf now connection
ListNew -> newTasks conf now connection
ListNewFiltered taskFilter -> newTasks conf now connection taskFilter
ListOld -> listOldTasks conf now connection
ListOpen -> openTasks conf now connection
ListModified -> modifiedTasks conf now connection AllItems
Expand Down Expand Up @@ -1304,7 +1306,7 @@ printOutput appName config = do
connection <- setupConnection configNorm

-- For debugging SQLite interactions
-- SQLite.setTrace connection $ Just P.print
-- SQLite.setTrace connection $ Just P.putStrLn

migrationsStatus <- runMigrations configNorm connection
nowElapsed <- timeCurrentP
Expand Down
Loading

0 comments on commit 9ab3992

Please sign in to comment.