This commit is contained in:
voidlizard 2025-02-05 13:56:48 +03:00
parent 227f29e8bb
commit f2f38c5ca9
2 changed files with 17 additions and 2 deletions

View File

@ -1652,12 +1652,24 @@ internalEntries = do
_ -> pure nil
entry $ bindMatch "pwd" $ const $ do
pwd <&> mkSym @c
entry $ bindMatch "cd" $ nil_ $ \case
[ StringLike dir ] -> cd dir
_ -> throwIO $ BadFormException @c nil
entry $ bindMatch "mkdir" $ nil_ $ \case
[ StringLike p ] -> mkdir p
[ ListVal (StringLikeList p) ] -> do
forM_ p mkdir
(StringLikeList p) -> forM_ p mkdir
_ -> throwIO $ BadFormException @c nil
entry $ bindMatch "rm" $ nil_ $ \case
[ StringLike p ] -> rm p
(StringLikeList p) -> forM_ p rm
[ ListVal (StringLikeList p) ] -> forM_ p rm
_ -> throwIO $ BadFormException @c nil
entry $ bindMatch "mv" $ nil_ $ \case

View File

@ -84,6 +84,9 @@ rm fn = liftIO $ D.removePathForcibly fn
home :: MonadIO m => m FilePath
home = liftIO D.getHomeDirectory
cd :: MonadIO m => FilePath -> m()
cd = liftIO . D.setCurrentDirectory
data DirEntry =
EntryFile { dirEntryPath :: FilePath }
| EntryDir { dirEntryPath :: FilePath }