Commit a5f728fd authored by Alexis Williams's avatar Alexis Williams Committed by Mikhail Glushenkov

Add aliases for new- commands that won't change at any point.

parent 402ebb84
......@@ -2,7 +2,7 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ViewPatterns #-}
module Distribution.Client.CmdLegacy ( legacyCmd, legacyWrapperCmd ) where
module Distribution.Client.CmdLegacy ( legacyCmd, legacyWrapperCmd, newCmd ) where
import Prelude ()
import Distribution.Client.Compat.Prelude
......@@ -159,3 +159,15 @@ legacyCmd ui action = toLegacyCmd (regularCmd ui action)
legacyWrapperCmd :: Monoid flags => CommandUI flags -> (flags -> Setup.Flag Verbosity) -> (flags -> Setup.Flag String) -> [CommandSpec (Client.GlobalFlags -> IO ())]
legacyWrapperCmd ui verbosity' distPref = toLegacyCmd (wrapperCmd ui verbosity' distPref)
newCmd :: CommandUI flags -> (flags -> [String] -> globals -> IO action) -> [CommandSpec (globals -> IO action)]
newCmd origUi@CommandUI{..} action = [cmd v2Ui, cmd origUi]
where
cmd ui = CommandSpec ui (flip commandAddAction action) NormalCommand
v2Msg = T.unpack . T.replace "new-" "v2-" . T.pack
v2Ui = origUi
{ commandName = v2Msg commandName
, commandUsage = v2Msg . commandUsage
, commandDescription = (v2Msg .) <$> commandDescription
, commandNotes = (v2Msg .) <$> commandDescription
}
......@@ -203,6 +203,7 @@ globalCommand commands = CommandUI {
, "new-install"
, "new-clean"
, "new-sdist"
-- v1 commands, stateful style
, "v1-build"
, "v1-configure"
, "v1-repl"
......@@ -221,6 +222,20 @@ globalCommand commands = CommandUI {
, "v1-register"
, "v1-reconfigure"
, "v1-sandbox"
-- v2 commands, nix-style
, "v2-build"
, "v2-configure"
, "v2-repl"
, "v2-freeze"
, "v2-run"
, "v2-test"
, "v2-bench"
, "v2-haddock"
, "v2-exec"
, "v2-update"
, "v2-install"
, "v2-clean"
, "v2-sdist"
]
maxlen = maximum $ [length name | (name, _) <- cmdDescs]
align str = str ++ replicate (maxlen - length str) ' '
......@@ -294,6 +309,21 @@ globalCommand commands = CommandUI {
, addCmd "new-clean"
, addCmd "new-sdist"
, par
, startGroup "new-style projects (forwards-compatible aliases)"
, addCmd "v2-build"
, addCmd "v2-configure"
, addCmd "v2-repl"
, addCmd "v2-run"
, addCmd "v2-test"
, addCmd "v2-bench"
, addCmd "v2-freeze"
, addCmd "v2-haddock"
, addCmd "v2-exec"
, addCmd "v2-update"
, addCmd "v2-install"
, addCmd "v2-clean"
, addCmd "v2-sdist"
, par
, startGroup "legacy command aliases"
, addCmd "v1-build"
, addCmd "v1-configure"
......
......@@ -303,21 +303,22 @@ mainWorker args = topHandler $
, hiddenCmd actAsSetupCommand actAsSetupAction
, hiddenCmd manpageCommand (manpageAction commandSpecs)
, regularCmd CmdConfigure.configureCommand CmdConfigure.configureAction
, regularCmd CmdUpdate.updateCommand CmdUpdate.updateAction
, regularCmd CmdBuild.buildCommand CmdBuild.buildAction
, regularCmd CmdRepl.replCommand CmdRepl.replAction
, regularCmd CmdFreeze.freezeCommand CmdFreeze.freezeAction
, regularCmd CmdHaddock.haddockCommand CmdHaddock.haddockAction
, regularCmd CmdInstall.installCommand CmdInstall.installAction
, regularCmd CmdRun.runCommand CmdRun.runAction
, regularCmd CmdTest.testCommand CmdTest.testAction
, regularCmd CmdBench.benchCommand CmdBench.benchAction
, regularCmd CmdExec.execCommand CmdExec.execAction
, regularCmd CmdClean.cleanCommand CmdClean.cleanAction
, regularCmd CmdSdist.sdistCommand CmdSdist.sdistAction
] ++ concat
[ legacyCmd configureExCommand configureAction
[ newCmd CmdConfigure.configureCommand CmdConfigure.configureAction
, newCmd CmdUpdate.updateCommand CmdUpdate.updateAction
, newCmd CmdBuild.buildCommand CmdBuild.buildAction
, newCmd CmdRepl.replCommand CmdRepl.replAction
, newCmd CmdFreeze.freezeCommand CmdFreeze.freezeAction
, newCmd CmdHaddock.haddockCommand CmdHaddock.haddockAction
, newCmd CmdInstall.installCommand CmdInstall.installAction
, newCmd CmdRun.runCommand CmdRun.runAction
, newCmd CmdTest.testCommand CmdTest.testAction
, newCmd CmdBench.benchCommand CmdBench.benchAction
, newCmd CmdExec.execCommand CmdExec.execAction
, newCmd CmdClean.cleanCommand CmdClean.cleanAction
, newCmd CmdSdist.sdistCommand CmdSdist.sdistAction
, legacyCmd configureExCommand configureAction
, legacyCmd updateCommand updateAction
, legacyCmd buildCommand buildAction
, legacyCmd replCommand replAction
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment