Skip to content

Commit

Permalink
Using quotation marks for arguments in repl, that allows for using sp…
Browse files Browse the repository at this point in the history
…aces/quotes in arguments
  • Loading branch information
unorsk committed Mar 22, 2023
1 parent c041be9 commit aa1c060
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion unison-cli/src/Unison/Codebase/TranscriptParser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import qualified Crypto.Random as Random
import qualified Data.Aeson as Aeson
import qualified Data.Aeson.Encode.Pretty as Aeson
import qualified Data.ByteString.Lazy.Char8 as BL
import Data.Char (isSpace)
import qualified Data.Char as Char
import qualified Data.Configurator as Configurator
import Data.Configurator.Types (Config)
Expand Down Expand Up @@ -71,7 +72,6 @@ import qualified Unison.Util.TQueue as Q
import qualified UnliftIO
import UnliftIO.STM
import Prelude hiding (readFile, writeFile)
import Data.Char (isSpace)

-- | Render transcript errors at a width of 65 chars.
terminalWidth :: Pretty.Width
Expand Down
15 changes: 8 additions & 7 deletions unison-cli/src/Unison/CommandLine.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ where
import Control.Concurrent (forkIO, killThread)
import Control.Lens (ifor)
import Control.Monad.Trans.Except
import Data.Char (isSpace)
import Data.Configurator (autoConfig, autoReload)
import qualified Data.Configurator as Config
import Data.Configurator.Types (Config, Worth (..))
Expand All @@ -50,7 +51,6 @@ import qualified Unison.Util.Pretty as P
import qualified Unison.Util.TQueue as Q
import UnliftIO.STM
import Prelude hiding (readFile, writeFile)
import Data.Char (isSpace)

disableWatchConfig :: Bool
disableWatchConfig = False
Expand Down Expand Up @@ -116,7 +116,7 @@ parseInput ::
-- | Input Pattern Map
Map String InputPattern ->
-- | command
String ->
String ->
-- | arguments string
String ->
IO (Either (P.Pretty CT.ColorText) Input)
Expand Down Expand Up @@ -157,11 +157,12 @@ words' s = case dropWhile isSpace s of
"" -> []
s'@('\"' : _) | [(w, s'')] <- reads s' -> w : words' s''
s' -> go id s'
where
go acc [] = [acc []]
go acc ('\\' : c : cs) | isSpace c = go (acc . (c :)) cs
go acc (c : cs) | isSpace c = acc [] : words' cs
| otherwise = go (acc . (c :)) cs
where
go acc [] = [acc []]
go acc ('\\' : c : cs) | isSpace c = go (acc . (c :)) cs
go acc (c : cs)
| isSpace c = acc [] : words' cs
| otherwise = go (acc . (c :)) cs

-- Expand a numeric argument like `1` or a range like `3-9`
expandNumber :: [String] -> String -> [String]
Expand Down
2 changes: 1 addition & 1 deletion unison-cli/src/Unison/CommandLine/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Control.Exception (catch, finally, mask)
import Control.Lens ((?~), (^.))
import Control.Monad.Catch (MonadMask)
import qualified Crypto.Random as Random
import Data.Char (isSpace)
import Data.Configurator.Types (Config)
import Data.IORef
import qualified Data.Text as Text
Expand Down Expand Up @@ -50,7 +51,6 @@ import qualified Unison.Util.Pretty as P
import qualified Unison.Util.TQueue as Q
import qualified UnliftIO
import UnliftIO.STM
import Data.Char (isSpace)

getUserInput ::
forall m v a.
Expand Down

0 comments on commit aa1c060

Please sign in to comment.