diff --git a/.fixme-new/config b/.fixme-new/config index eb48d693..f56ef141 100644 --- a/.fixme-new/config +++ b/.fixme-new/config @@ -52,3 +52,7 @@ fixme-comments ";" "--" (set-template default short) +(define (ls) (report)) + +(define (stage) (fixme:stage:show)) + diff --git a/fixme-new/lib/Fixme/Run.hs b/fixme-new/lib/Fixme/Run.hs index d9a0b2ea..c7691aa1 100644 --- a/fixme-new/lib/Fixme/Run.hs +++ b/fixme-new/lib/Fixme/Run.hs @@ -271,6 +271,27 @@ runTop forms = do fme <- lift listFixmies pure () + entry $ bindMatch "delete" $ nil_ \case + [FixmeHashLike hash] -> lift $ delete hash + + _ -> throwIO $ BadFormException @C nil + + entry $ bindMatch "modify" $ nil_ \case + [FixmeHashLike hash, StringLike a, StringLike b] -> do + lift $ modify_ hash a b + + _ -> throwIO $ BadFormException @C nil + + entry $ bindMatch "fixme:stage:show" $ nil_ $ const do + stage <- lift selectStage + liftIO $ print $ vcat (fmap pretty stage) + + entry $ bindMatch "fixme:stage:drop" $ nil_ $ const do + lift cleanStage + + entry $ bindMatch "fixme:stage:clean" $ nil_ $ const do + lift cleanStage + entry $ bindMatch "fixme:scan-git-local" $ nil_ $ const do lift $ scanGitLocal mempty Nothing @@ -304,5 +325,10 @@ runTop forms = do conf <- readConfig - run dict (conf <> forms) >>= eatNil display + argz <- liftIO getArgs + + let args = zipWith (\i s -> bindValue (mkId ("%" <> show i)) (mkStr @C s )) [1..] argz + & HM.unions + + run (dict <> args) (conf <> forms) >>= eatNil display diff --git a/fixme-new/lib/Fixme/Run/Internal.hs b/fixme-new/lib/Fixme/Run/Internal.hs index c1038e56..7b2c6bbe 100644 --- a/fixme-new/lib/Fixme/Run/Internal.hs +++ b/fixme-new/lib/Fixme/Run/Internal.hs @@ -291,3 +291,18 @@ cat_ metaOnly hash = do liftIO $ action dict (LBS8.unlines w) + +delete :: FixmePerks m => Text -> FixmeM m () +delete txt = do + acts <- asks fixmeEnvUpdateActions >>= readTVarIO + hashes <- selectFixmeHashes txt + for_ hashes $ \ha -> do + insertFixmeDelStaged ha + +modify_ :: FixmePerks m => Text -> String -> String -> FixmeM m () +modify_ txt a b = do + acts <- asks fixmeEnvUpdateActions >>= readTVarIO + void $ runMaybeT do + ha <- toMPlus =<< lift (selectFixmeHash txt) + lift $ insertFixmeModStaged ha (fromString a) (fromString b) + diff --git a/fixme-new/lib/Fixme/Types.hs b/fixme-new/lib/Fixme/Types.hs index 426873e6..7677f998 100644 --- a/fixme-new/lib/Fixme/Types.hs +++ b/fixme-new/lib/Fixme/Types.hs @@ -46,6 +46,9 @@ pattern TimeStampLike e <- (tsFromFromSyn -> Just e) class MkId a where mkId :: a -> Id +instance MkId String where + mkId s = fromString s + instance MkId FixmeAttrName where mkId (k :: FixmeAttrName) = Id ("$" <> coerce k)