Skip to content

Commit e8626d1

Browse files
committed
Merge branch 'feature/unpack-to' of https://github.com/SkyWriter/stack
2 parents b587f5f + a35700f commit e8626d1

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ Behavior changes:
1111

1212
Other enhancements:
1313

14+
* `stack unpack` now supports a `--to /target/directory` option to
15+
specify where to unpack the package into
16+
1417
Bug fixes:
1518
* When a package contained sublibraries, stack was always recompiling the
1619
package. This has been fixed now, no recompilation is being done because of

doc/GUIDE.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,13 @@ Unpacked yackage-0.8.0 to /var/home/harendra/yackage-0.8.0/
517517
cueball:~$ cd yackage-0.8.0/
518518
```
519519

520+
Note that you can also unpack to the directory of your liking instead of
521+
the current one by issueing:
522+
523+
```
524+
cueball:~$ stack unpack yackage-0.8.0 --to ~/work
525+
```
526+
520527
### stack init
521528
This new directory does not have a `stack.yaml` file, so we need to make one
522529
first. We could do it by hand, but let's be lazy instead with the `stack init`
@@ -1715,7 +1722,8 @@ users. Here's a quick rundown:
17151722
upstream packages available).
17161723
* `stack unpack` is a command we've already used quite a bit for examples, but
17171724
most users won't use it regularly. It does what you'd expect: downloads a
1718-
tarball and unpacks it.
1725+
tarball and unpacks it. It accept optional `--to` argument to specify
1726+
the destination directory.
17191727
* `stack sdist` generates an uploading tarball containing your package code
17201728
* `stack upload` uploads an sdist to Hackage. As of
17211729
version [1.1.0](https://docs.haskellstack.org/en/v1.1.0/ChangeLog/) stack

src/main/Main.hs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,9 @@ commandLineHandler currentDir progName isInterpreter = complicatedOptions
305305
addCommand' "unpack"
306306
"Unpack one or more packages locally"
307307
unpackCmd
308-
(some $ strArgument $ metavar "PACKAGE")
308+
((,) <$> some (strArgument $ metavar "PACKAGE")
309+
<*> optional (textOption $ long "to" <>
310+
help "Optional path to unpack the package into"))
309311
addCommand' "update"
310312
"Update the package index"
311313
updateCmd
@@ -650,10 +652,11 @@ uninstallCmd _ go = withConfigAndLock go $
650652
]
651653

652654
-- | Unpack packages to the filesystem
653-
unpackCmd :: [String] -> GlobalOpts -> IO ()
654-
unpackCmd names go = withConfigAndLock go $ do
655+
unpackCmd :: ([String], Maybe Text) -> GlobalOpts -> IO ()
656+
unpackCmd (names, Nothing) go = unpackCmd (names, Just ".") go
657+
unpackCmd (names, Just dstPath) go = withConfigAndLock go $ do
655658
mSnapshotDef <- mapM (makeConcreteResolver Nothing >=> loadResolver) (globalResolver go)
656-
Stack.Fetch.unpackPackages mSnapshotDef "." names
659+
Stack.Fetch.unpackPackages mSnapshotDef (T.unpack dstPath) names
657660

658661
-- | Update the package index
659662
updateCmd :: () -> GlobalOpts -> IO ()

0 commit comments

Comments
 (0)