summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2015-06-21 20:33:21 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2015-06-21 20:33:21 +0200
commit671d401b7b3d5a3d0733a84fbdebca355bd43176 (patch)
tree0be4ca68dfda4badf7ccc15365587714df011263
parent1b7643048e11da84216cd4e23d894a0767ee3061 (diff)
downloadtrivmix-671d401b7b3d5a3d0733a84fbdebca355bd43176.tar
trivmix-671d401b7b3d5a3d0733a84fbdebca355bd43176.tar.gz
trivmix-671d401b7b3d5a3d0733a84fbdebca355bd43176.tar.bz2
trivmix-671d401b7b3d5a3d0733a84fbdebca355bd43176.tar.xz
trivmix-671d401b7b3d5a3d0733a84fbdebca355bd43176.zip
locking in adjmix
-rw-r--r--adjmix/Adjmix.hs7
-rw-r--r--trivmix.cabal3
-rw-r--r--trivmix.nix2
3 files changed, 9 insertions, 3 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 @@
3import Options.Applicative 3import Options.Applicative
4 4
5import System.FilePath 5import System.FilePath
6import System.FileLock
6 7
7import Data.Char 8import 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
61adjmix :: Options -> IO () 66adjmix :: Options -> IO ()
62adjmix Options{..} = do 67adjmix 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
diff --git a/trivmix.cabal b/trivmix.cabal
index 803c640..54aad76 100644
--- a/trivmix.cabal
+++ b/trivmix.cabal
@@ -2,7 +2,7 @@
2-- documentation, see http://haskell.org/cabal/users-guide/ 2-- documentation, see http://haskell.org/cabal/users-guide/
3 3
4name: trivmix 4name: trivmix
5version: 2.5.2 5version: 2.5.3
6-- synopsis: 6-- synopsis:
7-- description: 7-- description:
8license: PublicDomain 8license: PublicDomain
@@ -48,6 +48,7 @@ executable adjmix
48 build-depends: base >=4.7 && <4.8 48 build-depends: base >=4.7 && <4.8
49 , optparse-applicative >=0.11 && <1 49 , optparse-applicative >=0.11 && <1
50 , filepath >=1.3 && <2 50 , filepath >=1.3 && <2
51 , filelock >=0.1 && <1
51 , trivmix 52 , trivmix
52 hs-source-dirs: adjmix 53 hs-source-dirs: adjmix
53 default-language: Haskell2010 54 default-language: Haskell2010
diff --git a/trivmix.nix b/trivmix.nix
index 298174b..d29bb48 100644
--- a/trivmix.nix
+++ b/trivmix.nix
@@ -6,7 +6,7 @@
6 6
7cabal.mkDerivation (self: { 7cabal.mkDerivation (self: {
8 pname = "trivmix"; 8 pname = "trivmix";
9 version = "2.5.2"; 9 version = "2.5.3";
10 src = ./.; 10 src = ./.;
11 isLibrary = true; 11 isLibrary = true;
12 isExecutable = true; 12 isExecutable = true;