Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d3ab4de

Browse files
committed
Feat: Add subcommand "deletetag"
1 parent 9bd552e commit d3ab4de

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

tasklite-core/app/Main.hs

+7
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ data Command
8484
{- Modify With Parameter -}
8585
| Prioritize Float [IdText]
8686
| AddTag TagText [IdText]
87+
| DeleteTag TagText [IdText]
8788
| AddNote Text [IdText]
8889
| SetDueUtc DateTime [IdText]
8990
| Start [IdText]
@@ -379,6 +380,11 @@ commandParser conf =
379380
<*> some (strArgument idsVar))
380381
"Add a tag to specified tasks")
381382

383+
<> command "deletetag" (toParserInfo (DeleteTag
384+
<$> strArgument (metavar "TAG" <> help "The tag")
385+
<*> some (strArgument idsVar))
386+
"Delete a tag from specified tasks")
387+
382388
<> command "note" (toParserInfo (AddNote
383389
<$> strArgument (metavar "NOTE" <> help "The note")
384390
<*> some (strArgument idsVar))
@@ -919,6 +925,7 @@ executeCLiCommand conf now connection cmd =
919925
NextTask -> nextTask conf connection
920926
FindTask aPattern -> findTask connection aPattern
921927
AddTag tagText ids -> addTag conf connection tagText ids
928+
DeleteTag tagText ids -> deleteTag conf connection tagText ids
922929
AddNote noteText ids -> addNote conf connection noteText ids
923930
SetDueUtc datetime ids -> setDueUtc conf connection datetime ids
924931
Duplicate ids -> duplicateTasks conf connection ids

tasklite-core/source/Lib.hs

+16
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,22 @@ addTag conf connection tag ids = do
10941094
pure $ vsep docs
10951095

10961096

1097+
deleteTag :: Config -> Connection -> Text -> [IdText] -> IO (Doc AnsiStyle)
1098+
deleteTag conf connection tag ids = do
1099+
docs <- forM ids $ \idSubstr -> do
1100+
execWithTask conf connection idSubstr $ \task -> do
1101+
runBeamSqlite connection $ runDelete $ delete
1102+
(_tldbTaskToTag taskLiteDb)
1103+
(\tagRecord ->
1104+
TaskToTag.task_ulid tagRecord ==. val_ (primaryKey task) &&.
1105+
(TaskToTag.tag tagRecord ==. val_ tag)
1106+
)
1107+
1108+
pure $ getResultMsg ("💥 Removed tag \"" <> pretty tag <> "\"") task
1109+
1110+
pure $ vsep docs
1111+
1112+
10971113
addNote :: Config -> Connection -> Text -> [IdText] -> IO (Doc AnsiStyle)
10981114
addNote conf connection noteBody ids = do
10991115
docs <- forM ids $ \idSubstr ->

0 commit comments

Comments
 (0)