Skip to content

Commit

Permalink
init: allow global --resolver in subcommand
Browse files Browse the repository at this point in the history
Now that there is no local --resolver option for stack init we can allow the
global option to be used in subcommand context.

This was disabled by the fix for commercialhaskell#1531. I have reverted the init specific fix for
that but kept the overall mechanism for any future use.
  • Loading branch information
harendra-kumar committed Jan 19, 2016
1 parent 63c7f48 commit da82ce9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
11 changes: 5 additions & 6 deletions src/Stack/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,12 @@ data BuildCommand
deriving (Eq)

-- | Allows adjust global options depending on their context
-- Note: This was being used to remove ambibuity between the local and global
-- implementation of stack init --resolver option. Now that stack init has no
-- local --resolver this is not being used anymore but the code is kept for any
-- similar future use cases.
data GlobalOptsContext
= OuterGlobalOpts -- ^ Global options before subcommand name
| InitCmdGlobalOpts -- ^ Global options following 'stack init'
| OtherCmdGlobalOpts -- ^ Global options following any other subcommand
deriving (Show, Eq)

Expand Down Expand Up @@ -637,11 +640,7 @@ globalOptsParser kind defLogLevel =
optional (option auto (long dockerEntrypointArgName <> hidden <> internal)) <*>
logLevelOptsParser hide0 defLogLevel <*>
configOptsParser hide0 <*>
(if kind == InitCmdGlobalOpts
-- The 'stack init' command has its own '--resolver' option, and having a global
-- one causes ambiguity, so disable it.
then pure Nothing
else optional (abstractResolverOptsParser hide0)) <*>
optional (abstractResolverOptsParser hide0) <*>
optional (compilerOptsParser hide0) <*>
maybeBoolFlags
"terminal"
Expand Down
4 changes: 1 addition & 3 deletions src/main/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,9 @@ commandLineHandler progName isInterpreter = complicatedOptions
"List the templates available for `stack new'."
templatesCmd
(pure ())
addCommand "init"
addCommand' "init"
"Initialize a stack project based on one or more cabal packages"
globalFooter
initCmd
(globalOpts InitCmdGlobalOpts)
initOptsParser
addCommand' "solver"
"Use a dependency solver to try and determine missing extra-deps"
Expand Down

0 comments on commit da82ce9

Please sign in to comment.