Skip to content

Commit

Permalink
Tidy up listDepsFormatOptsParser, for help output
Browse files Browse the repository at this point in the history
  • Loading branch information
mpilgrem committed Aug 7, 2024
1 parent 61117aa commit 67b7d70
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions .hlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
# the GHC2021 set. Other extensions can be added, if need be.
- name:
- NoImplicitPrelude
- ApplicativeDo
- ConstraintKinds
- DataKinds
- DefaultSignatures
Expand Down
21 changes: 13 additions & 8 deletions src/Stack/Options/LsParser.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE ApplicativeDo #-}
{-# LANGUAGE OverloadedStrings #-}

-- | Function to parse command line arguments for Stack's @ls@ command.
Expand All @@ -19,7 +20,7 @@ import Stack.Ls
, LsView (..), SnapshotOpts (..), ListGlobalsOpts
)
import Stack.Options.DotParser ( dotOptsParser )
import Stack.Prelude
import Stack.Prelude hiding ( sep )

-- | Parse command line arguments for Stack's @ls@ command.
lsOptsParser :: OA.Parser LsCmdOpts
Expand Down Expand Up @@ -48,9 +49,9 @@ lsDepsCmd :: OA.Mod OA.CommandFields LsCmds
lsDepsCmd = OA.command "dependencies" $
OA.info lsDepOptsParser $
OA.progDesc
"View the packages and versions used for a project. Use a command if \
\the first target specified has the name of a command. Targets other \
\than project packages are ignored."
"View the packages versions used for a project. Use a command if the \
\first target specified has the name of a command. Targets other than \
\project packages are ignored."
<> OA.footer globalFooter

lsStylesCmd :: OA.Mod OA.CommandFields LsCmds
Expand Down Expand Up @@ -193,17 +194,21 @@ listDepsJsonParser :: OA.Parser ListDepsFormat
listDepsJsonParser = pure ListDepsJSON

listDepsFormatOptsParser :: OA.Parser ListDepsFormatOpts
listDepsFormatOptsParser = ListDepsFormatOpts
<$> separatorParser
<*> licenseParser
listDepsFormatOptsParser = do
license <- licenseParser
sep <- separatorParser
pure ListDepsFormatOpts
{ sep
, license
}

separatorParser :: OA.Parser Text
separatorParser = fmap
escapeSep
( textOption
( OA.long "separator"
<> OA.metavar "SEP"
<> OA.help "Separator between package name and package version."
<> OA.help "Separator between package name and what follows."
<> OA.value " "
<> OA.showDefault
)
Expand Down

0 comments on commit 67b7d70

Please sign in to comment.