packages feed

cli-setup 0.2.0.5 → 0.2.0.6

raw patch · 6 files changed

+25/−54 lines, 6 filesdep +file-embeddep ~basePVP ok

version bump matches the API change (PVP)

Dependencies added: file-embed

Dependency ranges changed: base

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,5 +1,10 @@ # cli-setup +# 0.2.0.6+  +  * Use `TemplateHaskell` again+  * `writeBashCompletions` now only writes to `~/.bashrc` if the file exists+ ## 0.2.0.5    * Use `xxd` rather than `TemplateHaskell` to provide easier cross-platform
README.md view
@@ -8,9 +8,9 @@ import           Distribution.Simple  main :: IO ()-main = setManpath >>-    writeManpages "man/madlang.1" "madlang.1" >>-    writeBashCompletions "madlang" >>+main = setManpath *>+    writeManpages "man/madlang.1" "madlang.1" *>+    writeBashCompletions "madlang" *>     defaultMain ``` 
cabal.project.local view
@@ -1,2 +1,2 @@ constraints: cli-setup -development-documentation: True+documentation: true
− cbits/optparse-applicative.c
@@ -1,36 +0,0 @@-unsigned char py_optparse_applicative_py[] = {-  0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x20, 0x72, 0x65, 0x0a, 0x66, 0x72,-  0x6f, 0x6d, 0x20, 0x74, 0x68, 0x65, 0x66, 0x75, 0x63, 0x6b, 0x2e, 0x75,-  0x74, 0x69, 0x6c, 0x73, 0x20, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x20,-  0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x5f, 0x61, 0x72, 0x67, 0x75,-  0x6d, 0x65, 0x6e, 0x74, 0x0a, 0x0a, 0x64, 0x65, 0x66, 0x20, 0x6d, 0x61,-  0x74, 0x63, 0x68, 0x28, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x29,-  0x3a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e,-  0x20, 0x28, 0x27, 0x44, 0x69, 0x64, 0x20, 0x79, 0x6f, 0x75, 0x20, 0x6d,-  0x65, 0x61, 0x6e, 0x20, 0x74, 0x68, 0x69, 0x73, 0x3f, 0x27, 0x20, 0x69,-  0x6e, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x6f, 0x75,-  0x74, 0x70, 0x75, 0x74, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x27, 0x49, 0x6e,-  0x76, 0x61, 0x6c, 0x69, 0x64, 0x20, 0x61, 0x72, 0x67, 0x75, 0x6d, 0x65,-  0x6e, 0x74, 0x27, 0x20, 0x69, 0x6e, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61,-  0x6e, 0x64, 0x2e, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x29, 0x0a, 0x0a,-  0x64, 0x65, 0x66, 0x20, 0x67, 0x65, 0x74, 0x5f, 0x6e, 0x65, 0x77, 0x5f,-  0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x28, 0x63, 0x6f, 0x6d, 0x6d,-  0x61, 0x6e, 0x64, 0x29, 0x3a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x72,-  0x6f, 0x6b, 0x65, 0x6e, 0x20, 0x3d, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61,-  0x6e, 0x64, 0x2e, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x5f, 0x70, 0x61,-  0x72, 0x74, 0x73, 0x5b, 0x31, 0x5d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66,-  0x69, 0x78, 0x20, 0x3d, 0x20, 0x72, 0x65, 0x2e, 0x66, 0x69, 0x6e, 0x64,-  0x61, 0x6c, 0x6c, 0x28, 0x72, 0x27, 0x20, 0x20, 0x20, 0x20, 0x28, 0x5b,-  0x61, 0x2d, 0x7a, 0x41, 0x2d, 0x7a, 0x5d, 0x2a, 0x29, 0x27, 0x2c, 0x20,-  0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x6f, 0x75, 0x74, 0x70,-  0x75, 0x74, 0x29, 0x5b, 0x30, 0x5d, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20,-  0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x72, 0x65, 0x70, 0x6c, 0x61,-  0x63, 0x65, 0x5f, 0x61, 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x28,-  0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x73, 0x63, 0x72, 0x69,-  0x70, 0x74, 0x2c, 0x20, 0x62, 0x72, 0x6f, 0x6b, 0x65, 0x6e, 0x2c, 0x20,-  0x66, 0x69, 0x78, 0x29, 0x0a, 0x0a, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65,-  0x64, 0x5f, 0x62, 0x79, 0x5f, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74,-  0x20, 0x3d, 0x20, 0x54, 0x72, 0x75, 0x65, 0x0a, 0x0a, 0x70, 0x72, 0x69,-  0x6f, 0x72, 0x69, 0x74, 0x79, 0x20, 0x3d, 0x20, 0x31, 0x30, 0x30, 0x0a-};-unsigned int py_optparse_applicative_py_len = 396;
cli-setup.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.18 name: cli-setup-version: 0.2.0.5+version: 0.2.0.6 license: BSD3 license-file: LICENSE copyright: Copyright: (c) 2018 Vanessa McHale@@ -15,7 +15,6 @@ extra-source-files:     cabal.project.local     py/optparse-applicative.py-    cbits/*.c extra-doc-files: README.md                  CHANGELOG.md @@ -32,8 +31,6 @@ library     exposed-modules:         Distribution.CommandLine-    c-sources:-        cbits/optparse-applicative.c     hs-source-dirs: src     default-language: Haskell2010     ghc-options: -Wall@@ -41,11 +38,12 @@         base >=4.6 && <5,         directory -any,         process >=1.4.0.0,-        bytestring -any-    +        bytestring -any,+        file-embed >=0.0.9+     if flag(development)         ghc-options: -Werror-    +     if impl(ghc >=8.0)         ghc-options: -Wincomplete-uni-patterns -Wincomplete-record-updates                      -Wcompat
src/Distribution/CommandLine.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE TemplateHaskell #-}+ module Distribution.CommandLine     ( writeManpages     , writeBashCompletions@@ -7,13 +9,14 @@  import           Control.Applicative import           Control.Monad       (unless, void, when)-import           Foreign.C           (CString, peekCString)+import           Data.FileEmbed      (embedStringFile) import           System.Directory    (createDirectoryIfMissing,                                       doesDirectoryExist, doesFileExist) import           System.Environment  (lookupEnv) import           System.Process      (readCreateProcessWithExitCode, shell) -foreign import ccall unsafe py_optparse_applicative_py :: CString+rules :: String+rules = $(embedStringFile "py/optparse-applicative.py")  -- | Write a set of rules based on -- [optparse-applicative](http://hackage.haskell.org/package/optparse-applicative)@@ -22,7 +25,6 @@ writeTheFuck :: IO () writeTheFuck = do     h <- lookupEnv "HOME"-    rules <- peekCString py_optparse_applicative_py     case h of         Just h' -> do             proceed <- doesDirectoryExist (h' ++ "/.config/thefuck/rules")@@ -59,7 +61,7 @@         Just x -> do             let manPath = x ++ "/.local/share/man/man1"             createDirectoryIfMissing True manPath-            writeFile (manPath ++ "/" ++ p') =<< readFile p+            writeFile (manPath ++ "/" ++ p') =<< readFile p -- FIXME: do nothing on windows         Nothing -> pure ()  -- | Add a line to the user's @bashrc@ so that command-line completions work@@ -71,7 +73,9 @@     case home of         Just x -> do             let bashRc = x ++ "/.bashrc"-            config <- readFile bashRc-            unless (("# Added for " ++ exeName) `elem` lines config)-                (appendFile bashRc ("\n# Added for " ++ exeName ++ "\neval \"$(" ++ exeName ++ " --bash-completion-script " ++ exeName ++ ")\"\n"))+            b <- doesFileExist bashRc+            when b $ do+                config <- readFile bashRc+                unless (("# Added for " ++ exeName) `elem` lines config)+                    (appendFile bashRc ("\n# Added for " ++ exeName ++ "\neval \"$(" ++ exeName ++ " --bash-completion-script " ++ exeName ++ ")\"\n"))         Nothing -> pure ()