Safe Haskell | Safe-Inferred |
---|
Various functions used inside Gitson.
- documentPath :: FilePath -> String -> FilePath
- lockPath :: FilePath
- filterFilenamesAsKeys :: [FilePath] -> [String]
- filterDirs :: [FilePath] -> IO [FilePath]
- insideDirectory :: FilePath -> IO a -> IO a
- lastCommitText :: IO String
- shell :: String -> [String] -> IO ()
- intoFunctor :: Functor f => f a -> b -> f (a, b)
- maybeReadIntString :: String -> Maybe (Int, String)
- nextKeyId :: [String] -> Int
Documentation
documentPath :: FilePath -> String -> FilePathSource
Combines two paths and adds the .json extension.
>>>
documentPath "things" "document"
"things/document.json"
>>>
documentPath "things/" "document"
"things/document.json"
filterFilenamesAsKeys :: [FilePath] -> [String]Source
Turns a list of filenames into a list of keys, ignoring non-JSON files.
>>>
filterFilenamesAsKeys [".", "..", "k1.json", "unrelated.file"]
["k1"]
filterDirs :: [FilePath] -> IO [FilePath]Source
Filters a list of file paths, leaving only paths to existing non-hidden directories.
insideDirectory :: FilePath -> IO a -> IO aSource
Returns an IO action that switches the current directory to a given path, executes the given IO action and switches the current directory back.
lastCommitText :: IO StringSource
Returns the message of the last git commit in the repo where the current directory is located.
shell :: String -> [String] -> IO ()Source
Runs a shell command with stdin, stdout and stderr set to devnull.
intoFunctor :: Functor f => f a -> b -> f (a, b)Source
Appends a value to a functor, making the inside a tuple if it's a single value.
>>>
intoFunctor (Just 1) 2
Just (1,2)
>>>
intoFunctor Nothing 2
Nothing