hifi 0.1.1.0 → 0.1.2.0
raw patch · 3 files changed
+33/−3 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- hifi.cabal +1/−1
- src/Config.hs +27/−2
- src/Templating.hs +5/−0
hifi.cabal view
@@ -1,5 +1,5 @@ name: hifi-version: 0.1.1.0+version: 0.1.2.0 synopsis: WiFi connection script generator description: A CLI tool generating scripts for connecting to WiFi, circumventing big WiFi management tools. homepage: https://gitlab.com/gonz/hifi
src/Config.hs view
@@ -1,3 +1,10 @@+-- | Handles directory management for both the template data and the+-- data/scripts that the user generates when using 'hifi'. Internally it uses+-- '$XDG_DATA_HOME' to locate the directory where scripts and data files should+-- end up.+--+-- This usually defaults to '$HOME/.local' in most Linux distributions,+-- but can also be set manually if one chooses to do so. module Config (templateDir, dataDir, scriptDir) where import System.Directory@@ -6,11 +13,29 @@ createIfMissingPath :: FilePath -> IO FilePath createIfMissingPath path = createDirectoryIfMissing True path >> return path +-- | 'xdgDir' finds the user's '$XDG_DATA_HOME' directory and appends a given+-- path to it. '$XDG_DATA_HOME' defaults to '$HOME/.local' in many Linux+-- distributions, but can also be set manually.+xdgDir :: FilePath -> IO FilePath+xdgDir = getXdgDirectory XdgData++-- | 'templateDir' will point to the directory where the supplied data files (templates)+-- end up. The data dir will, when using `stack` end up in the `.stack-work`+-- folder. This directory is then used in order to read the templates at runtime+-- so that they can be used when writing new script/data files. templateDir :: IO FilePath templateDir = getDataFileName "templates" +-- | 'dataDir' points to a folder in the XDG data directory where it will store+-- the data files used to connect to networks. The subdirectory that will be used+-- is '$XDG_DATA_HOME/hifi/data'. If this directory does not already exist when+-- 'dataDir' is evaluated, it will be created. dataDir :: IO FilePath-dataDir = getXdgDirectory XdgData "hifi/data" >>= createIfMissingPath+dataDir = xdgDir "hifi/data" >>= createIfMissingPath +-- | 'scriptDir' points to a folder in the XDG data directory where it will store+-- the scripts it generates to connect to networks. The subdirectory that will be+-- used is '$XDG_DATA_HOME/hifi/scripts'. If this directory does not already exist when+-- 'scriptDir' is evaluated, it will be created. scriptDir :: IO FilePath-scriptDir = getXdgDirectory XdgData "hifi/scripts" >>= createIfMissingPath+scriptDir = xdgDir "hifi/scripts" >>= createIfMissingPath
src/Templating.hs view
@@ -1,5 +1,7 @@ {-# LANGUAGE OverloadedStrings #-} +-- | Handles the execution of 'wpa_*' commands as well as the template loading,+-- compilation and substitution. module Templating (createFiles) where import qualified Config@@ -57,6 +59,9 @@ TextIO.writeFile outputPath $ substitute template spec return (Right outputPath) +-- | 'createFiles' creates both the script- and data-file for a 'FilePath',+-- 'Interface', 'SSID' and 'Passphrase'. These filenames are then returned in a+-- tuple so that they may be used to notify the user of their creation. createFiles :: FilePath -> Interface -> SSID -> Passphrase -> IO (FilePath, FilePath) createFiles filename iface ssid passphrase = do