6
6
module Stack.Ls
7
7
( lsCmd
8
8
, lsParser
9
- , listDependenciesCmd
10
9
) where
11
10
12
11
import Control.Exception (throw )
@@ -30,6 +29,7 @@ import RIO.PrettyPrint (useColorL)
30
29
import RIO.PrettyPrint.DefaultStyles (defaultStyles )
31
30
import RIO.PrettyPrint.Types (StyleSpec )
32
31
import RIO.PrettyPrint.StylesUpdate (StylesUpdate (.. ), stylesUpdateL )
32
+ import Stack.Constants (osIsWindows )
33
33
import Stack.Dot
34
34
import Stack.Runners
35
35
import Stack.Options.DotParser (listDepsOptsParser )
@@ -132,12 +132,10 @@ lsViewSnapCmd =
132
132
OA. help " Only show nightly snapshots" )
133
133
134
134
lsSnapCmd :: OA. Mod OA. CommandFields LsCmds
135
- lsSnapCmd =
136
- OA. command
137
- " snapshots"
138
- (OA. info
139
- lsCmdOptsParser
140
- (OA. progDesc " View local snapshot (default option)" ))
135
+ lsSnapCmd = OA. command " snapshots" $
136
+ OA. info lsCmdOptsParser $
137
+ OA. progDesc " View snapshots (local by default)"
138
+ <> OA. footer localSnapshotMsg
141
139
142
140
lsDepsCmd :: OA. Mod OA. CommandFields LsCmds
143
141
lsDepsCmd =
@@ -254,7 +252,10 @@ handleLocal :: LsCmdOpts -> RIO Runner ()
254
252
handleLocal lsOpts = do
255
253
(instRoot :: Path Abs Dir ) <- withConfig YesReexec $ withDefaultEnvConfig installationRootDeps
256
254
isStdoutTerminal <- view terminalL
257
- let snapRootDir = parent $ parent instRoot
255
+ let parentInstRoot = parent instRoot
256
+ snapRootDir
257
+ | osIsWindows = parentInstRoot
258
+ | otherwise = parent parentInstRoot
258
259
snapData' <- liftIO $ listDirectory $ toFilePath snapRootDir
259
260
let snapData = L. sort snapData'
260
261
case lsView lsOpts of
@@ -307,30 +308,30 @@ lsCmd lsOpts =
307
308
case soptViewType of
308
309
Local -> handleLocal lsOpts
309
310
Remote -> handleRemote lsOpts
310
- LsDependencies depOpts -> listDependenciesCmd False depOpts
311
+ LsDependencies depOpts -> listDependencies depOpts
311
312
LsStyles stylesOpts -> withConfig NoReexec $ listStylesCmd stylesOpts
312
313
LsTools toolsOpts -> withConfig NoReexec $ listToolsCmd toolsOpts
313
314
314
- -- | List the dependencies
315
- listDependenciesCmd :: Bool -> ListDepsOpts -> RIO Runner ()
316
- listDependenciesCmd deprecated opts = do
317
- when
318
- deprecated
319
- (logWarn
320
- " DEPRECATED: Use ls dependencies instead. Will be removed in next major version." )
321
- listDependencies opts
322
-
323
315
lsViewLocalCmd :: OA. Mod OA. CommandFields LsView
324
- lsViewLocalCmd =
325
- OA. command
326
- " local"
327
- ( OA. info ( pure Local ) ( OA. progDesc " View local snapshot " ))
316
+ lsViewLocalCmd = OA. command " local " $
317
+ OA. info ( pure Local ) $
318
+ OA. progDesc " View local snapshots "
319
+ <> OA. footer localSnapshotMsg
328
320
329
321
lsViewRemoteCmd :: OA. Mod OA. CommandFields LsView
330
- lsViewRemoteCmd =
331
- OA. command
332
- " remote"
333
- (OA. info (pure Remote ) (OA. progDesc " View remote snapshot" ))
322
+ lsViewRemoteCmd = OA. command " remote" $
323
+ OA. info (pure Remote ) $
324
+ OA. progDesc " View remote snapshots"
325
+ <> OA. footer pagerMsg
326
+
327
+ pagerMsg :: String
328
+ pagerMsg =
329
+ " On a terminal, uses a pager, if one is available. Respects the PAGER \
330
+ \environment variable (subject to that, prefers pager 'less' to 'more')."
331
+
332
+ localSnapshotMsg :: String
333
+ localSnapshotMsg =
334
+ " A local snapshot is identified by a hash code. " <> pagerMsg
334
335
335
336
-- | List stack's output styles
336
337
listStylesCmd :: ListStylesOpts -> RIO Config ()
0 commit comments