Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszcz committed Nov 29, 2024
1 parent f343096 commit ee57060
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
19 changes: 15 additions & 4 deletions app/Commands/Clean.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,20 @@ import Commands.Clean.Options

runCommand :: (Members '[Files, App] r) => CleanOptions -> Sem r ()
runCommand opts
| opts ^. cleanOptionsOnlyGlobal = do
cleanGlobal
| opts ^. cleanOptionsGlobal = do
configDir <- juvixConfigDir
whenM (directoryExists' configDir) (removeDirectoryRecursive' configDir)
cleanGlobal
cleanLocal
| otherwise = do
buildDir <- askBuildDir
whenM (directoryExists' buildDir) (removeDirectoryRecursive' buildDir)
cleanLocal

cleanGlobal :: (Members '[Files, App] r) => Sem r ()
cleanGlobal = do
configDir <- juvixConfigDir
whenM (directoryExists' configDir) (removeDirectoryRecursive' configDir)

cleanLocal :: (Members '[Files, App] r) => Sem r ()
cleanLocal = do
buildDir <- askBuildDir
whenM (directoryExists' buildDir) (removeDirectoryRecursive' buildDir)
13 changes: 10 additions & 3 deletions app/Commands/Clean/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ module Commands.Clean.Options where
import CommonOptions
import Juvix.Extra.Version

newtype CleanOptions = CleanOptions
{_cleanOptionsGlobal :: Bool}
data CleanOptions = CleanOptions
{ _cleanOptionsGlobal :: Bool,
_cleanOptionsOnlyGlobal :: Bool
}
deriving stock (Data)

makeLenses ''CleanOptions
Expand All @@ -15,6 +17,11 @@ parseCleanOptions = do
switch
( long "global"
<> short 'g'
<> help ("Remove $XDG_CONFIG_HOME/juvix/" <> unpack versionDoc)
<> help ("Remove also $XDG_CONFIG_HOME/juvix/" <> unpack versionDoc)
)
_cleanOptionsOnlyGlobal <-
switch
( long "global-only"
<> help ("Remove only $XDG_CONFIG_HOME/juvix/" <> unpack versionDoc)
)
pure CleanOptions {..}

0 comments on commit ee57060

Please sign in to comment.