cli-setup 0.2.0.7 → 0.2.1.0
raw patch · 4 files changed
+51/−28 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Distribution.CommandLine: setManpathBash :: IO ()
+ Distribution.CommandLine: setManpathFish :: IO ()
+ Distribution.CommandLine: setManpathZsh :: IO ()
Files
- CHANGELOG.md +4/−0
- LICENSE +1/−1
- cli-setup.cabal +25/−24
- src/Distribution/CommandLine.hs +21/−3
CHANGELOG.md view
@@ -1,5 +1,9 @@ # cli-setup +# 0.2.1.0++ * Add `setManpathBash` & co., deprecate `setManpath`+ # 0.2.0.6 * Use `TemplateHaskell` again
LICENSE view
@@ -1,4 +1,4 @@-Copyright Vanessa McHale (c) 2018+Copyright Vanessa McHale (c) 2018-2019 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
cli-setup.cabal view
@@ -1,38 +1,39 @@-cabal-version: 1.18-name: cli-setup-version: 0.2.0.7-license: BSD3-license-file: LICENSE-copyright: Copyright: (c) 2018-2019 Vanessa McHale-maintainer: vanessa.mchale@iohk.io-author: Vanessa McHale-synopsis: Helper setup scripts for packaging command-line tools.+cabal-version: 1.18+name: cli-setup+version: 0.2.1.0+license: BSD3+license-file: LICENSE+copyright: Copyright: (c) 2018-2019 Vanessa McHale+maintainer: vamchale@gmail.com+author: Vanessa McHale+synopsis: Helper setup scripts for packaging command-line tools. description: Provides functions to set up manpages and shell completions. Intended to be used in the @Setup.hs@ module.-category: Development, Command Line Tools-build-type: Simple++category: Development, Command Line Tools+build-type: Simple extra-source-files: cabal.project py/optparse-applicative.py-extra-doc-files: README.md- CHANGELOG.md +extra-doc-files:+ README.md+ CHANGELOG.md+ source-repository head- type: darcs+ type: darcs location: https://hub.darcs.net/vmchale/cli-setup flag development- description:- Enable `-Werror`- default: False- manual: True+ description: Enable `-Werror`+ default: False+ manual: True library- exposed-modules:- Distribution.CommandLine- hs-source-dirs: src+ exposed-modules: Distribution.CommandLine+ hs-source-dirs: src default-language: Haskell2010- ghc-options: -Wall+ ghc-options: -Wall build-depends: base >=4.6 && <5, directory -any,@@ -44,5 +45,5 @@ ghc-options: -Werror if impl(ghc >=8.0)- ghc-options: -Wincomplete-uni-patterns -Wincomplete-record-updates- -Wcompat+ ghc-options:+ -Wincomplete-uni-patterns -Wincomplete-record-updates -Wcompat
src/Distribution/CommandLine.hs view
@@ -3,6 +3,9 @@ module Distribution.CommandLine ( writeManpages , writeBashCompletions+ , setManpathBash+ , setManpathZsh+ , setManpathFish , setManpath , writeTheFuck ) where@@ -33,17 +36,32 @@ -- | Add a line exporting the modified @MANPATH@ to the user's @bashrc@, if it -- does not exist already.+--+-- @since 0.2.1.0+setManpathBash :: IO ()+setManpathBash = setManpathGeneric ".bashrc"++setManpathZsh :: IO ()+setManpathZsh = setManpathGeneric ".zshrc"++setManpathFish :: IO ()+setManpathFish = setManpathGeneric ".config/fish/config.fish"+ setManpath :: IO ()-setManpath = do+setManpath = setManpathBash+{-# DEPRECATED setManpath "Use setManpathBash or setManpathZsh" #-}++setManpathGeneric :: FilePath -> IO ()+setManpathGeneric fp = do home <- lookupEnv "HOME" case home of Just x -> do- let bashRc = x ++ "/.bashrc"+ let bashRc = x ++ "/" ++ fp b <- doesFileExist bashRc when b $ do config <- readFile bashRc unless ("#manpath updated by cli-setup" `elem` lines config)- (appendFile bashRc "\n#manpath updated by cli-setup\nexport MANPATH=~/.local/share:$MANPATH\n" *>+ (appendFile bashRc "\n#manpath updated by cli-setup\nexport MANPATH=$HOME/.local/share:$MANPATH\n" *> void (readCreateProcessWithExitCode (shell $ "MANPATH=" ++ x ++ "/.local/share mandb") "")) Nothing -> pure ()