Skip to content

Commit

Permalink
command sequencing and haskeline support
Browse files Browse the repository at this point in the history
  • Loading branch information
fcostantini committed Sep 30, 2016
1 parent bd8c6c1 commit 5168816
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
4 changes: 2 additions & 2 deletions PlEb.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: PlEb
version: 1.1.1
version: 1.1.2
synopsis: A simple tool to edit and export playlists
license: GPL-3
license-file: LICENSE
Expand All @@ -11,4 +11,4 @@ executable PlEb
hs-source-dirs: src
main-is: Main.hs
default-language: Haskell2010
build-depends: base, xml, directory, filepath, strict, parsec, network-uri
build-depends: base, directory, filepath, haskeline, network-uri, parsec, strict, transformers, xml
16 changes: 14 additions & 2 deletions src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ module Main where

import Control.Exception
import Control.Monad
import Control.Monad.IO.Class
import Data.Char
import Data.List
import Data.Maybe
import System.Console.Haskeline
import System.Directory
import System.Environment
import System.Exit
Expand Down Expand Up @@ -73,13 +75,23 @@ runArgs (Playlist f) = load True f
runArgs Wrong = putStrLn "Incorrect execution. Use -h for help" >> exitSuccess

menu :: Bool -> Playlist -> IO Playlist
menu b pl = do let pname = F.takeBaseName (getPath pl)
{-menu b pl = do let pname = F.takeBaseName (getPath pl)
when b (putStrLn $ "\nPlaylist " ++ pname ++ " loaded.\n\nAvailable commands: add, add_dir, check, combine, convert, exit/quit, export, help, load, print, rmv. Use help for further information.\n")
putStr ">"
hFlush stdout
input <- getLine
cmd <- parseComd (input++"\n")
runCmd cmd pl >>= (\p -> menu False p)
runCmd cmd pl >>= (\p -> menu False p)-}
menu b pl = (runInputT (defaultSettings {historyFile = hfile}) loop) >>= (\p -> menu False p)
where loop :: InputT IO Playlist
loop = do let pname = F.takeBaseName (getPath pl)
when b $ liftIO (putStrLn $ "\nPlaylist " ++ pname ++ " loaded.\n\nAvailable commands: add, add_dir, check, combine, convert, exit/quit, export, help, load, print, rmv. Use help for further information.\n")
input <- getInputLine "> "
case input of
Nothing -> return pl
Just c -> do cmd <- liftIO $ parseComd (c++"\n")
liftIO $ runCmd cmd pl
hfile = Just ".PlEb_history" -- fixed path?

trim :: String -> String
trim = filter (/= ' ')
Expand Down
10 changes: 6 additions & 4 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ packages:
- '.'
# Dependency packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3)
extra-deps:
- xml-1.3.14
- directory-1.2.6.3
- directory-1.2.7.0
- filepath-1.4.1.0
- strict-0.3.2
- parsec-3.1.11
- haskeline-0.7.2.3
- network-uri-2.6.1.0
- parsec-3.1.11
- transformers-0.4.2.0
- strict-0.3.2
- xml-1.3.14

# Override default flag values for local packages and extra-deps
flags: {}
Expand Down

0 comments on commit 5168816

Please sign in to comment.