packages feed

cli-setup 0.1.0.3 → 0.2.0.0

raw patch · 3 files changed

+40/−2 lines, 3 filesdep +file-embedPVP ok

version bump matches the API change (PVP)

Dependencies added: file-embed

API changes (from Hackage documentation)

+ Distribution.CommandLine: writeTheFuck :: IO ()

Files

cli-setup.cabal view
@@ -1,5 +1,5 @@ name:                cli-setup-version:             0.1.0.3+version:             0.2.0.0 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. homepage:            https://github.com/vmchale/cli-setup#readme@@ -13,6 +13,7 @@ extra-doc-files:     README.md extra-source-files:  stack.yaml                    , cabal.project.local+                   , py/optparse-applicative.py cabal-version:       >=1.18  Flag development {@@ -28,6 +29,7 @@                      , directory                      , process >= 1.4.0.0                      , bytestring+                     , file-embed   default-language:    Haskell2010   if flag(development)     ghc-options:       -Werror
+ py/optparse-applicative.py view
@@ -0,0 +1,15 @@+import re+from thefuck.utils import replace_argument++def match(command):+    return ('Did you mean this?' in command.output and 'Invalid argument' in command.output)++def get_new_command(command):+    broken = command.script_parts[1]+    fix = re.findall(r'    ([a-zA-z]*)', command.output)[0]++    return replace_argument(command.script, broken, fix)++enabled_by_default = True++priority = 100
src/Distribution/CommandLine.hs view
@@ -1,13 +1,34 @@+{-# LANGUAGE TemplateHaskell #-}+ module Distribution.CommandLine     ( writeManpages     , writeBashCompletions     , setManpath+    , writeTheFuck     ) where +import           Data.Bool          (bool) import           Control.Monad      (unless, void)-import           System.Directory   (createDirectoryIfMissing)+import           System.Directory   (createDirectoryIfMissing, doesDirectoryExist) import           System.Environment (lookupEnv) import           System.Process     (readCreateProcessWithExitCode, shell)+import           Data.FileEmbed     (embedStringFile)++rules :: String+rules = $(embedStringFile "py/optparse-applicative.py")++-- | Write a set of rules based on+-- [optparse-applicative](http://hackage.haskell.org/package/optparse-applicative)+-- for the command-line tool+-- [fuck](https://pypi.python.org/pypi/thefuck/).+writeTheFuck :: IO ()+writeTheFuck = do+    h <- lookupEnv "HOME"+    case h of+        Just h' -> do+            proceed <- doesDirectoryExist (h' ++ "/.config/thefuck/rules")+            bool (pure ()) (writeFile rules (h' ++ "/.config/thefuck/rules/optparse-applicative.py")) proceed+        Nothing -> pure ()  -- | Add a line exporting the modified @MANPATH@ to the user's @bashrc@, if it -- does not exist already.