Skip to content

Commit

Permalink
You can see how many letters you type when input password
Browse files Browse the repository at this point in the history
  • Loading branch information
applePrincess committed Apr 14, 2018
1 parent 15ad905 commit 1283534
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 6 additions & 2 deletions app/CommentReader/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import Control.Monad (when)
import qualified Data.ByteString as B
import Data.IORef
import Data.List (elemIndices)
import Data.Maybe (fromJust)
import Data.Semigroup ((<>))
import qualified Data.Text as T
import qualified Data.Text.Encoding as TE
import Data.Word
import System.IO (hFlush, hGetEcho, hSetEcho, stdin,
stdout)
import qualified System.Console.Haskeline as HS
import System.IO.Unsafe (unsafePerformIO)
import System.Process (createProcess, shell)

Expand Down Expand Up @@ -149,7 +151,7 @@ sendToSoftalk spath (T.unpack . TE.decodeUtf8 . B.drop 15 -> msg) = do
let process = shell $ spath ++ " /X:1 /W:" ++ msg
_<- createProcess process
return ()

{-
getPassword :: IO String
getPassword = do
putStr "Password: "
Expand All @@ -163,7 +165,9 @@ getPassword = do
else drop (last idx + 1) pass
hSetEcho stdin _oldEcho
return pass'

-}
getPassword :: IO String
getPassword = HS.runInputT HS.defaultSettings $ HS.getPassword (Just '·') "Password: " >>= return . fromJust

formatMessage :: Chat -> String -> T.Text
formatMessage c fStr = T.replace (T.pack "\\t") (T.pack "\t") $
Expand Down
9 changes: 6 additions & 3 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ executables:
main: Main.hs
source-dirs: app/SampleBot
dependencies:
- mimizu
- containers
- mimizu

chat:
main: Main.hs
source-dirs: app/CommentReader
dependencies:
- directory
- haskeline
- mimizu
- process
- optparse-applicative
- directory
- process

0 comments on commit 1283534

Please sign in to comment.