Skip to content

Commit

Permalink
fix init and format
Browse files Browse the repository at this point in the history
  • Loading branch information
janmasrovira committed Jul 19, 2024
1 parent 8266534 commit 9a4f78d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion app/Commands/Format.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ formatProject ::
forall r.
(Members '[App, EmbedIO, TaggedLock, Logger, Files, Output FormattedFileInfo] r) =>
Sem r FormatResult
formatProject = runPipelineOptions . runPipelineSetup $ do
formatProject = silenceProgressLog . runPipelineOptions . runPipelineSetup $ do
pkg <- askPackage
res :: [(ImportNode, PipelineResult ModuleInfo)] <- processProject
res' :: [(ImportNode, SourceCode)] <- runReader pkg . forM res $ \(node, nfo) -> do
Expand Down
24 changes: 12 additions & 12 deletions app/Commands/Init.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ init :: forall r. (Members '[EmbedIO, App] r) => InitOptions -> Sem r ()
init opts = do
checkNotInProject
cwd <- getCurrentDir
when isInteractive (renderStdOut ("creating " <> pack (toFilePath packageFilePath)))
when isInteractive (renderStdOutLn ("creating " <> pack (toFilePath packageFilePath)))
if
| opts ^. initOptionsBasic -> writeBasicPackage cwd
| otherwise -> do
pkg <-
if
| isInteractive -> do
renderStdOut @Text "✨ Your next Juvix adventure is about to begin! ✨"
renderStdOut @Text "I will help you set it up"
renderStdOutLn @Text "✨ Your next Juvix adventure is about to begin! ✨"
renderStdOutLn @Text "I will help you set it up"
getPackage
| otherwise -> do
projectName <- getDefaultProjectName
Expand All @@ -46,7 +46,7 @@ init opts = do
Just n -> emptyPkg {_packageName = n}
writePackageFile cwd pkg
checkPackage
when isInteractive (renderStdOut @Text "you are all set")
when isInteractive (renderStdOutLn @Text "you are all set")
where
isInteractive :: Bool
isInteractive = not (opts ^. initOptionsNonInteractive) && not (opts ^. initOptionsBasic)
Expand All @@ -57,7 +57,7 @@ checkNotInProject =
where
err :: Sem r ()
err = do
renderStdOut @Text "You are already in a Juvix project"
renderStdOutLn @Text "You are already in a Juvix project"
exitFailure

checkPackage :: forall r. (Members '[EmbedIO, App] r) => Sem r ()
Expand All @@ -66,14 +66,14 @@ checkPackage = do
ep <- runError @JuvixError (runTaggedLockPermissive (loadPackageFileIO cwd DefaultBuildDir))
case ep of
Left {} -> do
renderStdOut @Text "Package.juvix is invalid. Please raise an issue at https://github.com/anoma/juvix/issues"
renderStdOutLn @Text "Package.juvix is invalid. Please raise an issue at https://github.com/anoma/juvix/issues"
exitFailure
Right {} -> return ()

getPackage :: forall r. (Members '[EmbedIO, App] r) => Sem r Package
getPackage = do
tproj <- getProjName
renderStdOut @Text "Write the version of your project [leave empty for 0.0.0]"
renderStdOutLn @Text "Write the version of your project [leave empty for 0.0.0]"
tversion :: SemVer <- getVersion
cwd <- getCurrentDir
return
Expand All @@ -99,7 +99,7 @@ getProjName = do
defMsg = case d of
Nothing -> mempty
Just d' -> " [leave empty for '" <> d' <> "']"
renderStdOut
renderStdOutLn
( "Write the name of your project"
<> defMsg
<> " (lower case letters, numbers and dashes are allowed): "
Expand All @@ -119,7 +119,7 @@ getProjName = do
Right p
| Text.length p <= projextNameMaxLength -> return p
| otherwise -> do
renderStdOut ("The project name cannot exceed " <> prettyText projextNameMaxLength <> " characters")
renderStdOutLn ("The project name cannot exceed " <> prettyText projextNameMaxLength <> " characters")
retry
Left err -> do
renderStdOut err
Expand All @@ -131,7 +131,7 @@ getProjName = do
go

tryAgain :: (Members '[App] r) => Sem r ()
tryAgain = renderStdOut @Text "Please, try again:"
tryAgain = renderStdOutLn @Text "Please, try again:"

getVersion :: forall r. (Members '[App, EmbedIO] r) => Sem r SemVer
getVersion = do
Expand All @@ -141,8 +141,8 @@ getVersion = do
| otherwise -> case parse semver' txt of
Right r -> return r
Left err -> do
renderStdOut err
renderStdOut @Text "The version must follow the 'Semantic Versioning 2.0.0' specification"
renderStdOutLn err
renderStdOutLn @Text "The version must follow the 'Semantic Versioning 2.0.0' specification"
retry
where
retry :: Sem r SemVer
Expand Down

0 comments on commit 9a4f78d

Please sign in to comment.