Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make CLI format format #1459

Merged
merged 3 commits into from
Aug 26, 2023
Merged
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
11 changes: 7 additions & 4 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import Options.Applicative
import Swarm.App (appMain)
import Swarm.Doc.Gen (EditorType (..), GenerateDocs (..), PageAddress (..), SheetType (..), generateDocs)
import Swarm.Language.LSP (lspMain)
import Swarm.Language.Pipeline (processTerm)
import Swarm.Language.Parse (readTerm)
import Swarm.Language.Pretty (prettyText)
import Swarm.TUI.Model (AppOpts (..), ColorMode (..))
import Swarm.TUI.Model.UI (defaultInitLgTicksPerSecond)
import Swarm.Version
Expand Down Expand Up @@ -160,9 +161,11 @@ showInput (File fp) = pack fp
formatFile :: Input -> IO ()
formatFile input = do
content <- getInput input
case processTerm content of
Right _ -> do
Text.putStrLn content
case readTerm content of
Right t -> do
case t of
Nothing -> Text.putStrLn ""
Just ast -> Text.putStrLn $ prettyText ast
exitSuccess
Left e -> do
Text.hPutStrLn stderr $ showInput input <> ":" <> e
Expand Down
Loading