Skip to content

Commit 09b6039

Browse files
neilmayhewaniketd
authored andcommitted
Improve scripts/generate-release-changelog-links.hs
Add a CLI flag to write output to a file so that cabal output and progress messages aren't mixed in with it
1 parent d0dcd9b commit 09b6039

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

RELEASE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,6 @@ There's a script (`scripts/generate-release-changelog-links.hs`) that generates
9191
> example usage (be sure to run `cabal build all` at least once beforehand):
9292
> ```
9393
> $ nix build .#project.x86_64-linux.plan-nix.json
94-
> $ ./scripts/generate-release-changelog-links.hs result-json $GITHUB_API_TOKEN
94+
> $ ./scripts/generate-release-changelog-links.hs result-json $GITHUB_API_TOKEN -o links.md
9595
> ```
9696
> for more information, including how to generate / retrieve a GitHub API token, use `./scripts/generate-release-changelog-links.hs --help`

scripts/generate-release-changelog-links.hs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env -S cabal run --verbose=1 --index-state=2024-04-09T14:49:48Z
1+
#!/usr/bin/env -S cabal --verbose=1 --index-state=2024-04-09T14:49:48Z run --
22
{- cabal:
33
build-depends:
44
base,
@@ -47,6 +47,7 @@ import Data.Map.Strict (Map)
4747
import qualified Data.Map.Strict as Map
4848
import Data.Maybe
4949
import qualified Data.Text as Text
50+
import qualified Data.Text.IO as Text
5051
import qualified Data.Text.Encoding as Text
5152
import Data.Version
5253
import qualified GitHub
@@ -65,10 +66,11 @@ import Turtle
6566
main :: IO ()
6667
main = sh do
6768

68-
(planJsonFilePath, gitHubAccessToken) <-
69-
options generateReleaseChangelogLinksDescription do
70-
(,) <$> argPath "plan_json_path" "Path of the plan.json file"
71-
<*> fmap (GitHubAccessToken . Text.encodeUtf8) (argText "github_access_token" "GitHub personal access token")
69+
(outputPath, planJsonFilePath, gitHubAccessToken) <-
70+
options generateReleaseChangelogLinksDescription $
71+
(,,) <$> optPath "output" 'o' "Write the generated links to OUTPUT"
72+
<*> argPath "plan_json_path" "Path of the plan.json file"
73+
<*> fmap (GitHubAccessToken . Text.encodeUtf8) (argText "github_access_token" "GitHub personal access token")
7274

7375
packagesMap <- getCHaPPackagesMap
7476

@@ -97,7 +99,7 @@ main = sh do
9799
case pandocOutput of
98100
Left pandocError -> die $
99101
"Failed to render markdown with error " <> Pandoc.renderError pandocError
100-
Right res -> printf (s%"\n") res
102+
Right res -> liftIO . Text.writeFile outputPath $ format (s%"\n") res
101103

102104
generateReleaseChangelogLinksDescription :: Description
103105
generateReleaseChangelogLinksDescription = Description $

0 commit comments

Comments
 (0)