-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
45 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,36 @@ | ||
module Main where | ||
|
||
import Control.Concurrent.Async (race_) | ||
import GHC.Conc.Sync (atomically, STM) | ||
import Options.Applicative (execParser) | ||
import Args | ||
import Itunes | ||
import Actions (getAction) | ||
import Channel | ||
|
||
main :: IO () | ||
main = execParser app >>= run | ||
|
||
run :: Args -> IO () | ||
run = putStrLn . show | ||
run args = let | ||
action = getAction (actionType args) | ||
channel = newChannel 500 -- wild ass guess | ||
transform = mkTransform (target args) (attributes args) | ||
in | ||
(race_ (readSources channel transform [source args]) | ||
(doAction channel action)) >> | ||
putStrLn "finished" | ||
|
||
escape :: Transform -> Action -> [Directory] -> IO () | ||
escape = undefined | ||
readSources :: STM (Channel Copy) -> Transform -> [Directory] -> IO () | ||
readSources _ _ [] = return () | ||
readSources chan t (d:ds) = do | ||
(dirs, copies) <- handleDirectory d t | ||
atomically $ enqueueCopies chan copies | ||
readSources chan t (ds ++ dirs) | ||
|
||
enqueueCopies :: STM (Channel Copy) -> [Copy] -> STM () | ||
enqueueCopies chan cs = chan >>= writeChan cs | ||
|
||
doAction :: STM (Channel Copy) -> Action -> IO () | ||
doAction chan action = | ||
atomically (chan >>= readChan) >>= action |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters