packages feed

cabal-gild 0.2.0.1 → 0.2.1.0

raw patch · 6 files changed

+93/−73 lines, 6 files

Files

+ CHANGELOG.md view
@@ -0,0 +1,4 @@+# Change log++cabal-gild follows the [Package Versioning Policy](https://pvp.haskell.org).+You can find release notes [on GitHub](https://github.com/tfausak/cabal-gild/releases).
− Changelog.md
@@ -1,66 +0,0 @@-# 0.1.10--- Fix removal of empty lines in free text fields (like `description`)-  when using `cabal-version: 3.0` (where you can use empty lines)--# 0.1.9--- Change how version ranges with carets are formatted once again.-  Now `^>=1.2 || ^>=1.3` won't be changed anymore.--# 0.1.8--- Order extensions lexicographically--# 0.1.7--- Use Cabal-syntax-3.10.1.0--# 0.1.6--- Fix filepath issues on Windows-- Add support for sublibraries-- Format `build-tool-depends`-- Use Cabal-syntax-3.8.1.0-- Smarter version range normaliser--# 0.1.5.1--- Fix bug in pretty printing empty version ranges.--# 0.1.5--- Don't print redundant `-any` in `impl`-- Add `glob-files` pragma for source file fields (`c-sources`, ...)-  Glob syntax supports only stars (i.e. no `{}` etc. extras).-- Source file fields are now sorted--# 0.1.4--- Add `-n` / `--no-cabal-file` to format cabal like, but not package files.-  Useful to format `cabal.project` or `cabal.haskell-ci`.-- Add `fragment` pragma to substitute a field or a section with-  contents of external file.-  Useful in multi-package setting to keep for example-  `tested-with` field or `common deps` stanza in sync.--# 0.1.3--- GHC-8.10 support. Require Cabal-3.2-- Add `--check` operation mode--# 0.1.2--- Don't change current working directories. Don't expand if used on stdin.-- Sort module names case-insensitively--# 0.1.1--- Change metavar of file arguments to be `FILE...`,-  to imply that multiple files at once are supported-- Add `expand src -ModuleName1 -ModuleName2` support-- Add `--tabular` and `--no-tabular` configuraiton options-- Add `-Werror` option (there are some warnings)-- Preserve end file comments-- More pretty `tested-with` formatting-- Add `--version` flag
+ README.md view
@@ -0,0 +1,63 @@+# cabal-gild++## Synopsis++```sh+$ cabal install cabal-gild+$ ...+$ cabal-gild --inplace example.cabal+```++## Output++Turns this...++```cabal+cabal-version: 2.4+name: cabal-gild+version: 0++-- An example formatter+executable cabal-gild+    default-language: Haskell2010+    hs-source-dirs: src+    main-is: CabalGild.hs+    -- build depends will be in+    -- a nice tabular format+    build-depends: base >=4.11 && <4.13, pretty >=1.1.3.6 && <1.2, bytestring, Cabal ^>=2.5, containers ^>=0.5.11.0 || ^>=0.6.0.1+    -- extensions will be sorted+    other-extensions:+      DeriveFunctor FlexibleContexts ExistentialQuantification OverloadedStrings+      RankNTypes+```++...into this:++```cabal+cabal-version: 2.4+name:          cabal-gild+version:       0++-- An example formatter+executable cabal-gild+  default-language: Haskell2010+  hs-source-dirs:   src+  main-is:          CabalGild.hs++  -- build depends will be in+  -- a nice tabular format+  build-depends:+    , base        >=4.11      && <4.13+    , bytestring+    , Cabal       ^>=2.5+    , containers  ^>=0.5.11.0 || ^>=0.6.0.1+    , pretty      >=1.1.3.6   && <1.2++  -- extensions will be sorted+  other-extensions:+    DeriveFunctor+    ExistentialQuantification+    FlexibleContexts+    OverloadedStrings+    RankNTypes+```
cabal-gild.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.2 name:               cabal-gild-version:            0.2.0.1+version:            0.2.1.0 synopsis:           Format .cabal files category:           Development description:@@ -12,7 +12,10 @@ license-file:       LICENSE.txt author:             Oleg Grenrus <oleg.grenrus@iki.fi> maintainer:         Taylor Fausak-extra-doc-files:    Changelog.md+extra-doc-files:+  CHANGELOG.md+  README.md+ extra-source-files:   fixtures/*.cabal   fixtures/*.format
source/library/CabalGild/Main.hs view
@@ -4,7 +4,7 @@ module CabalGild.Main (main) where  import CabalGild (cabalGild)-import CabalGild.Error (renderError)+import CabalGild.Error (Error (SomeError), renderError) import CabalGild.Monad (runCabalGildIO) import CabalGild.Options import CabalGild.Prelude@@ -53,8 +53,17 @@   -- name of the input   let filepath = fromMaybe "<stdin>" mfilepath +  mroot <-+    fmap takeDirectory <$> case (mfilepath, optStdinInputFile opts) of+      (Just _, Just _) -> do+        renderError $ SomeError "cannot pass both --stdin-input-file and FILE"+        exitFailure+      (Just f, Nothing) -> pure $ Just f+      (Nothing, Just f) -> pure $ Just f+      (Nothing, Nothing) -> pure Nothing+   -- process-  res <- runCabalGildIO (takeDirectory <$> mfilepath) opts (cabalGild filepath input)+  res <- runCabalGildIO mroot opts (cabalGild filepath input)    case res of     Right output -> do@@ -96,7 +105,8 @@               noCabalFileP,               stdoutP,               inplaceP,-              checkP+              checkP,+              rootP             ]      werrorP =@@ -138,3 +148,7 @@     checkP =       O.flag' (mkOptionsMorphism $ \opts -> opts {optMode = ModeCheck}) $         O.short 'c' <> O.long "check" <> O.help "Fail with non-zero exit code if input is not formatted"++    rootP =+      O.option (fmap (\f -> mkOptionsMorphism $ \opts -> opts {optStdinInputFile = Just f}) O.str) $+        O.long "stdin-input-file" <> O.help "When reading from STDIN, use this file path to resolve relative references" <> O.metavar "FILE"
source/library/CabalGild/Options.hs view
@@ -27,7 +27,8 @@     optTabular :: !Bool,     optCabalFile :: !Bool,     optSpecVersion :: !C.CabalSpecVersion,-    optMode :: !Mode+    optMode :: !Mode,+    optStdinInputFile :: !(Maybe FilePath)   }   deriving (Show) @@ -39,7 +40,8 @@       optTabular = True,       optCabalFile = True,       optSpecVersion = C.cabalSpecLatest,-      optMode = ModeStdout+      optMode = ModeStdout,+      optStdinInputFile = Nothing     }  newtype OptionsMorphism = OM (Options -> Options)