Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Add the ability to specify the project directory #16

Merged
merged 1 commit into from
Aug 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.stack-work
.unison/
.unisonHistory
scratch.u
11 changes: 9 additions & 2 deletions Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ import qualified UCE
import UCE.Prelude

data Config = Config
{ configPort :: Int
{ configPort :: Int,
directory :: String
}
deriving (Show)

main :: IO ()
main = do
logLn "Starting"
conf <- runParser
UCE.run (configPort conf)
UCE.run (configPort conf) (directory conf)
where
runParser :: IO Config
runParser =
Expand Down Expand Up @@ -49,3 +50,9 @@ main = do
<> value 8080
<> showDefault
)
<*> strOption
( long "directory"
<> help "Project directory to explore"
<> value "."
<> showDefault
)
6 changes: 3 additions & 3 deletions src/UCE.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import qualified UCE.Code
import UCE.Prelude
import qualified UCE.UI

run :: Int -> IO ()
run port = do
codeinfo <- UCE.Code.load
run :: Int -> String -> IO ()
run port projectDirectory = do
codeinfo <- UCE.Code.load projectDirectory
Concur.Replica.Run.run
port
index
Expand Down
15 changes: 7 additions & 8 deletions src/UCE/Code.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,20 @@ shallowReferences :: Reference -> DependencyGraph -> Set Reference
shallowReferences ref (DependencyGraph deps) =
Map.findWithDefault mempty ref (Relation.range deps)

load :: IO CodeInfo
load =
loadCodeInfo =<< loadCodebaseAndBranch
load :: String -> IO CodeInfo
load projectDirectory =
loadCodeInfo =<< loadCodebaseAndBranch projectDirectory

loadCodebaseAndBranch :: IO (Codebase IO Symbol Ann, Branch0 IO)
loadCodebaseAndBranch = do
loadCodebaseAndBranch :: String -> IO (Codebase IO Symbol Ann, Branch0 IO)
loadCodebaseAndBranch projectDirectory = do
let codebasePath :: FilePath
codebasePath =
".unison/v1"
codebasePath = projectDirectory <> "/.unison/v1"
codebase :: Codebase IO Symbol Ann
codebase =
FileCodebase.codebase1 formatSymbol formatAnn codebasePath

exists <- FileCodebase.exists codebasePath
when (not exists) (die "No codebase found")
when (not exists) (die ("No codebase found in " <> codebasePath))

branch <- Codebase.getRootBranch codebase

Expand Down