diff options
Diffstat (limited to 'adjmix')
-rw-r--r-- | adjmix/Adjmix.hs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/adjmix/Adjmix.hs b/adjmix/Adjmix.hs index 645ac6a..94416ac 100644 --- a/adjmix/Adjmix.hs +++ b/adjmix/Adjmix.hs | |||
@@ -3,6 +3,7 @@ | |||
3 | import Options.Applicative | 3 | import Options.Applicative |
4 | 4 | ||
5 | import System.FilePath | 5 | import System.FilePath |
6 | import System.FileLock | ||
6 | 7 | ||
7 | import Data.Char | 8 | import Data.Char |
8 | 9 | ||
@@ -20,6 +21,7 @@ optionParser = Options | |||
20 | <> metavar "DIRECTORY" | 21 | <> metavar "DIRECTORY" |
21 | <> value "/dev/shm/mix" | 22 | <> value "/dev/shm/mix" |
22 | <> showDefault | 23 | <> showDefault |
24 | <> help "Base directory" | ||
23 | ) | 25 | ) |
24 | <*> strOption ( long "target" | 26 | <*> strOption ( long "target" |
25 | <> short 't' | 27 | <> short 't' |
@@ -35,16 +37,19 @@ optionParser = Options | |||
35 | <*> ( ( Set <$> option auto ( long "set" | 37 | <*> ( ( Set <$> option auto ( long "set" |
36 | <> short 'o' | 38 | <> short 'o' |
37 | <> metavar "LEVEL" | 39 | <> metavar "LEVEL" |
40 | <> help "Overwrite the current level" | ||
38 | ) | 41 | ) |
39 | ) | 42 | ) |
40 | <|> ( Add <$> option auto ( long "add" | 43 | <|> ( Add <$> option auto ( long "add" |
41 | <> short 'a' | 44 | <> short 'a' |
42 | <> metavar "LEVEL" | 45 | <> metavar "LEVEL" |
46 | <> help "Add to the current level" | ||
43 | ) | 47 | ) |
44 | ) | 48 | ) |
45 | <|> ( Sub <$> option auto ( long "sub" | 49 | <|> ( Sub <$> option auto ( long "sub" |
46 | <> short 's' | 50 | <> short 's' |
47 | <> metavar "LEVEL" | 51 | <> metavar "LEVEL" |
52 | <> help "Subtract from the current level" | ||
48 | ) | 53 | ) |
49 | ) | 54 | ) |
50 | ) | 55 | ) |
@@ -59,7 +64,7 @@ main = execParser opts >>= adjmix | |||
59 | ) | 64 | ) |
60 | 65 | ||
61 | adjmix :: Options -> IO () | 66 | adjmix :: Options -> IO () |
62 | adjmix Options{..} = do | 67 | adjmix Options{..} = withFileLock levelFile' Exclusive $ const $ do |
63 | oldLevel <- readFile levelFile' >>= readIO . stripSpace | 68 | oldLevel <- readFile levelFile' >>= readIO . stripSpace |
64 | let | 69 | let |
65 | newLevel = oldLevel `doAdjustment` adjustment | 70 | newLevel = oldLevel `doAdjustment` adjustment |