Skip to content

Commit 01e7f5c

Browse files
Release 0.2.0.0
2 parents 78844a6 + e98817a commit 01e7f5c

File tree

12 files changed

+221
-115
lines changed

12 files changed

+221
-115
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ following conventions:
2424

2525
[KaC]: <https://keepachangelog.com/en/1.0.0/>
2626

27+
## 0.2.0.0 (2023-05-28)
28+
29+
### Breaking
30+
31+
* Add support for `optparse-applicative` `0.18`
32+
33+
### Non-Breaking
34+
35+
* Bump `ansi-wl-pprint` dependency version upper bound
36+
2737
## 0.1.1.0 (2023-04-23)
2838

2939
### Non-Breaking

Makefile

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ endif
124124

125125
clean-all: clean
126126
clean-all: # clean package and remove artifacts
127-
> @rm -rf .hie
128127
> @rm -rf .stack-work
129128
> @rm -rf build
130129
> @rm -rf dist-newstyle
@@ -370,17 +369,6 @@ source-tar: # create source tarball using tar
370369
> @rm -f build/.gitignore
371370
.PHONY: source-tar
372371

373-
stan: hr
374-
stan: export STAN_USE_DEFAULT_CONFIG=True
375-
stan: # run stan static analysis
376-
ifeq ($(MODE), cabal)
377-
> @cabal v2-build -f write-hie
378-
else
379-
> @stack build --flag $(PACKAGE):write-hie
380-
endif
381-
> @stan
382-
.PHONY: stan
383-
384372
test: hr
385373
test: # run tests, optionally for pattern P *
386374
> $(eval P := "")
@@ -396,7 +384,7 @@ else
396384
endif
397385
.PHONY: test
398386

399-
test-all: # run all configured tests and build examples using MODE
387+
test-all: # run all configured tests using MODE
400388
> @./test-all.sh "$(MODE)"
401389
.PHONY: test-all
402390

app/LibOA.hs

Lines changed: 66 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,21 @@
99
-- @optparse-applicative@. I do not feel that it is worth maintaining yet
1010
-- another helper package on Hackage, so I just copy the code to different
1111
-- projects as required. If the library grows to a substantial size or others
12-
-- with to use it, I will reconsider.
12+
-- want to use it, I will reconsider.
1313
--
14-
-- Revision: 2022-01-02
14+
-- Revision: 2023-05-26
1515
------------------------------------------------------------------------------
1616

1717
{-# LANGUAGE CPP #-}
1818
{-# LANGUAGE LambdaCase #-}
1919
{-# LANGUAGE TupleSections #-}
2020

21+
#if defined(MIN_VERSION_ansi_wl_pprint)
22+
#if MIN_VERSION_ansi_wl_pprint (1,0,2)
23+
{-# OPTIONS_GHC -Wno-warnings-deprecations #-}
24+
#endif
25+
#endif
26+
2127
module LibOA
2228
( -- * Options
2329
-- $Options
@@ -28,14 +34,23 @@ module LibOA
2834
-- * Help
2935
, (<||>)
3036
, section
37+
, section'
3138
, table
3239
, table_
3340
, vspace
41+
-- ** Compatibility
42+
, Doc
43+
, (<$$>)
44+
, empty
45+
, string
46+
, vcat
3447
) where
3548

3649
-- https://hackage.haskell.org/package/ansi-wl-pprint
50+
#if !MIN_VERSION_optparse_applicative (0,18,0)
3751
import qualified Text.PrettyPrint.ANSI.Leijen as Doc
3852
import Text.PrettyPrint.ANSI.Leijen (Doc)
53+
#endif
3954

4055
-- https://hackage.haskell.org/package/base
4156
import Data.List (intersperse, transpose)
@@ -50,8 +65,16 @@ import qualified Options.Applicative as OA
5065
import qualified Options.Applicative.Builder.Internal as OABI
5166
#endif
5267
import qualified Options.Applicative.Common as OAC
68+
#if MIN_VERSION_optparse_applicative (0,18,0)
69+
import Options.Applicative.Help.Pretty (Doc)
70+
#endif
5371
import qualified Options.Applicative.Types as OAT
5472

73+
-- https://hackage.haskell.org/package/prettyprinter
74+
#if MIN_VERSION_optparse_applicative (0,18,0)
75+
import qualified Prettyprinter as Doc
76+
#endif
77+
5578
------------------------------------------------------------------------------
5679
-- $Options
5780
--
@@ -103,8 +126,12 @@ versioner verStr = OA.infoOption verStr $ mconcat
103126
commands :: OA.Parser a -> [String]
104127
commands =
105128
let go _ opt = case OAT.optMain opt of
129+
#if MIN_VERSION_optparse_applicative (0,18,0)
130+
OAT.CmdReader _ cmdPs -> reverse $ fst <$> cmdPs
131+
#else
106132
OAT.CmdReader _ cmds _ -> reverse cmds
107-
_otherReader -> []
133+
#endif
134+
_otherReader -> []
108135
in concat . OAC.mapParser go
109136

110137
------------------------------------------------------------------------------
@@ -115,22 +142,26 @@ commands =
115142
d1 <||> d2 = d1 <> Doc.line <> Doc.line <> d2
116143
infixr 5 <||>
117144

118-
-- | Create a section with a title and indented body
145+
-- | Create a section with a title and body indented by 2 spaces
119146
section :: String -> Doc -> Doc
120-
section title = (Doc.text title Doc.<$$>) . Doc.indent 2
147+
section = section' 2
148+
149+
-- | Create a section with a title and body indented by specified spaces
150+
section' :: Int -> String -> Doc -> Doc
151+
section' numSpaces title = (string title <$$>) . Doc.indent numSpaces
121152

122153
-- | Create a table, with formatting
123154
table :: Int -> [[(String, Doc -> Doc)]] -> Doc
124155
table sep rows = Doc.vcat $
125-
map (fromMaybe Doc.empty . foldr go Nothing . zip lengths) rows
156+
map (fromMaybe empty . foldr go Nothing . zip lengths) rows
126157
where
127158
lengths :: [Int]
128159
lengths = map ((+) sep . maximum . map (length . fst)) $ transpose rows
129160

130161
go :: (Int, (String, Doc -> Doc)) -> Maybe Doc -> Maybe Doc
131162
go (len, (s, f)) = Just . \case
132-
Just doc -> Doc.fill len (f $ Doc.string s) <> doc
133-
Nothing -> f $ Doc.string s
163+
Just doc -> Doc.fill len (f $ string s) <> doc
164+
Nothing -> f $ string s
134165

135166
-- | Create a table, without formatting
136167
table_ :: Int -> [[String]] -> Doc
@@ -139,3 +170,30 @@ table_ sep = table sep . (map . map) (, id)
139170
-- | Vertically space documents with blank lines between them
140171
vspace :: [Doc] -> Doc
141172
vspace = mconcat . intersperse (Doc.line <> Doc.line)
173+
174+
------------------------------------------------------------------------------
175+
-- $Compatibility
176+
177+
(<$$>) :: Doc -> Doc -> Doc
178+
#if MIN_VERSION_optparse_applicative (0,18,0)
179+
l <$$> r = l <> Doc.line <> r
180+
#else
181+
(<$$>) = (Doc.<$$>)
182+
#endif
183+
184+
empty :: Doc
185+
#if MIN_VERSION_optparse_applicative (0,18,0)
186+
empty = Doc.emptyDoc
187+
#else
188+
empty = Doc.empty
189+
#endif
190+
191+
string :: String -> Doc
192+
#if MIN_VERSION_optparse_applicative (0,18,0)
193+
string = Doc.pretty
194+
#else
195+
string = Doc.string
196+
#endif
197+
198+
vcat :: [Doc] -> Doc
199+
vcat = Doc.vcat

bm.cabal

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: bm
2-
version: 0.1.1.0
2+
version: 0.2.0.0
33
category: Utils
44
synopsis: open bookmarks and queries from the command line
55
description:
@@ -22,9 +22,9 @@ tested-with:
2222
|| ==8.8.4
2323
|| ==8.10.7
2424
|| ==9.0.2
25-
|| ==9.2.7
25+
|| ==9.2.8
2626
|| ==9.4.5
27-
|| ==9.6.1
27+
|| ==9.6.2
2828

2929
extra-source-files:
3030
CHANGELOG.md
@@ -34,9 +34,11 @@ source-repository head
3434
type: git
3535
location: https://github.com/ExtremaIS/bm-haskell.git
3636

37-
flag write-hie
38-
description: write .hie files
37+
-- This flag is referenced in the Stack build-constraints.yaml configuration.
38+
flag optparse-applicative_ge_0_18
39+
description: Use optparse-applicative 0.18 or newer
3940
default: False
41+
manual: False
4042

4143
library
4244
hs-source-dirs: src
@@ -56,25 +58,28 @@ library
5658
default-language: Haskell2010
5759
default-extensions:
5860
OverloadedStrings
59-
if flag(write-hie)
60-
ghc-options: -Wall -fwrite-ide-info -hiedir=.hie
61-
else
62-
ghc-options: -Wall
61+
ghc-options: -Wall
6362

6463
executable bm
6564
hs-source-dirs: app
6665
main-is: Main.hs
6766
other-modules:
6867
LibOA
6968
build-depends:
70-
ansi-wl-pprint >=0.6.8 && <0.7
71-
, base
69+
base
7270
, bm
7371
, directory >=1.3.3 && <1.4
7472
, filepath >=1.4.2.1 && <1.5
75-
, optparse-applicative >=0.14 && <0.18
7673
, typed-process >=0.2.6 && <0.3
7774
, yaml >=0.11.2 && <0.12
75+
if flag(optparse-applicative_ge_0_18)
76+
build-depends:
77+
optparse-applicative >=0.18 && <0.19
78+
, prettyprinter >=1.7.1 && <1.8
79+
else
80+
build-depends:
81+
ansi-wl-pprint >=0.6.8 && <1.1
82+
, optparse-applicative >=0.14 && <0.18
7883
default-language: Haskell2010
7984
ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N
8085

cabal-bounds-upper.project

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
packages: ./bm.cabal
22

3-
with-compiler: ghc-9.6.1
3+
with-compiler: ghc-9.6.2
44

55
constraints:
66
-- https://hackage.haskell.org/package/aeson
77
, aeson == 2.1.2.1
88

9-
-- https://hackage.haskell.org/package/ansi-wl-pprint
10-
, ansi-wl-pprint == 0.6.9
11-
129
-- https://hackage.haskell.org/package/base
1310
-- GHC boot library
1411
, base == 4.18.0.0
@@ -28,7 +25,10 @@ constraints:
2825
, network-uri == 2.6.4.2
2926

3027
-- https://hackage.haskell.org/package/optparse-applicative
31-
, optparse-applicative == 0.17.0.0
28+
, optparse-applicative == 0.18.0.0
29+
30+
-- https://hackage.haskell.org/package/prettyprinter
31+
, prettyprinter == 1.7.1
3232

3333
-- https://hackage.haskell.org/package/scientific
3434
, scientific == 0.3.7.0

doc/bm.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
. ftr VB CB
1515
. ftr VBI CBI
1616
.\}
17-
.TH "BM" "1" "" "bm-haskell 0.1.1.0 (2023-04-23)" "bm Manual"
17+
.TH "BM" "1" "" "bm-haskell 0.2.0.0 (2023-05-28)" "bm Manual"
1818
.nh
1919
.SH NAME
2020
.PP
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# `bm-haskell` `0.2.0.0` Release Notes
2+
3+
Date
4+
: 2023-05-28
5+
6+
## Overview
7+
8+
`bm` is a utility for opening bookmarks and queries from the command line.
9+
The bookmarks and queries are configured hierarchically in YAML, and they are
10+
referenced using keyword prefixes. It allows you to quickly open bookmarks
11+
and perform search queries in your browser using only your keyboard.
12+
13+
See the [README][] for details.
14+
15+
[README]: <https://github.com/ExtremaIS/bm-haskell#readme>
16+
17+
## This Release
18+
19+
This release adds compatibility with the latest version of the
20+
`optparse-applicative` library.
21+
22+
There are no changes to the API or CLI.
23+
24+
### Compatibility
25+
26+
To use this release with a Stackage snapshot that does not include it, add
27+
the following to your `stack.yaml` configuration:
28+
29+
```yaml
30+
extra-deps:
31+
- bm-0.2.0.0
32+
```
33+
34+
### Issues
35+
36+
There are no known issues at this time.

stack-9.2.7.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
resolver: lts-20.18
1+
resolver: lts-20.23
22

33
packages:
44
- .

0 commit comments

Comments
 (0)