main :: IO ()
main = do
    -- Version code from stack. Maybe move this stuff into optparse-simple ?
    let commitCount = $gitCommitCount
        versionString' = concat $ concat
            [ [$(simpleVersion Meta.version)]
              -- Leave out number of commits for --depth=1 clone
              -- See https://github.com/commercialhaskell/stack/issues/792
            , [" (" ++ commitCount ++ " commits)" | commitCount /= ("1"::String) &&
                                                    commitCount /= ("UNKNOWN" :: String)]
            , [" ", display buildArch]
            ]
        numericVersion :: Parser (a -> a)
        numericVersion =
            infoOption
                (showVersion Meta.version)
                (long "numeric-version" <>
                 help "Show only version number")
    -- Parse the options and run the specified command.
    (global, run) <-
        simpleOptions
            versionString'
            "HaRe - the haskell refactorer"
            ""
            -- (numericVersion <*> globalOptsParser) $
            (numericVersion <*> allOptsParser) $
            do
              addCommand "demote"
                         "Demote a declaration"
                         runCmd
                         demoteCmdOpts

              addCommand "dupdef"
                         "Duplicate a definition"
                         runCmd
                         dupDefCmdOpts

              addCommand "iftocase"
                         "Convert an if statement to a case statement"
                         runCmd
                         ifToCaseCmdOpts

              addCommand "liftOneLevel"
                         "Lift a definition up one level"
                         runCmd
                         liftOneLevelCmdOpts

              addCommand "liftToTopLevel"
                         "Lift a definition to the top level"
                         runCmd
                         liftToTopLevelCmdOpts

              addCommand "rename"
                         "Rename an identifier"
                         runCmd
                         renameCmdOpts

              addCommand "addOneParam"
                         "Add a new parameter to a function in first position"
                         runCmd
                         addOneParamCmdOpts

              addCommand "rmOneParam"
                         "Remove a new parameter from a function"
                         runCmd
                         rmOneParamCmdOpts
    run global

-- ---------------------------------------------------------------------
main :: IO ()
main = do
    -- Version code from stack. Maybe move this stuff into optparse-simple ?
    let commitCount = $gitCommitCount
        versionString' = concat $ concat
            [ [$(simpleVersion Meta.version)]
              -- Leave out number of commits for --depth=1 clone
              -- See https://github.com/commercialhaskell/stack/issues/792
            , [" (" ++ commitCount ++ " commits)" | commitCount /= ("1"::String) &&
                                                    commitCount /= ("UNKNOWN" :: String)]
            , [" ", display buildArch]
            ]
        numericVersion :: Parser (a -> a)
        numericVersion =
            infoOption
                (showVersion Meta.version)
                (long "numeric-version" <>
                 help "Show only version number")
    -- Parse the options and run the specified command.
    (global, run) <-
        simpleOptions
            versionString'
            "HaRe - the haskell refactorer"
            ""
            -- (numericVersion <*> globalOptsParser) $
            (numericVersion <*> allOptsParser) $
            do
              addCommand "demote"
                         "Demote a declaration"
                         runCmd
                         demoteCmdOpts

              addCommand "dupdef"
                         "Duplicate a definition"
                         runCmd
                         dupDefCmdOpts

              addCommand "iftocase"
                         "Convert an if statement to a case statement"
                         runCmd
                         ifToCaseCmdOpts

              addCommand "liftOneLevel"
                         "Lift a definition up one level"
                         runCmd
                         liftOneLevelCmdOpts

              addCommand "liftToTopLevel"
                         "Lift a definition to the top level"
                         runCmd
                         liftToTopLevelCmdOpts

              addCommand "rename"
                         "Rename an identifier"
                         runCmd
                         renameCmdOpts

              addCommand "addOneParam"
                         "Add a new parameter to a function in first position"
                         runCmd
                         addOneParamCmdOpts

              addCommand "rmOneParam"
                         "Remove a new parameter from a function"
                         runCmd
                         rmOneParamCmdOpts
    run global

-- ---------------------------------------------------------------------
main = do
    -- Version code from stack. Maybe move this stuff into optparse-simple ?
    let commitCount = $gitCommitCount
        versionString' = concat $ concat
            [ [$(simpleVersion Meta.version)]
              -- Leave out number of commits for --depth=1 clone
              -- See https://github.com/commercialhaskell/stack/issues/792
            , [" (" ++ commitCount ++ " commits)" | commitCount /= ("1"::String) &&
                                                    commitCount /= ("UNKNOWN" :: String)]
            , [" ", display buildArch]
            ]
        numericVersion :: Parser (a -> a)
        numericVersion =
            infoOption
                (showVersion Meta.version)
                (long "numeric-version" <>
                 help "Show only version number")
    -- Parse the options and run the specified command.
    (global, run) <-
        simpleOptions
            versionString'
            "HaRe - the haskell refactorer"
            ""
            -- (numericVersion <*> globalOptsParser) $
            (numericVersion <*> allOptsParser) $
            do
              addCommand "demote"
                         "Demote a declaration"
                         runCmd
                         demoteCmdOpts

              addCommand "dupdef"
                         "Duplicate a definition"
                         runCmd
                         dupDefCmdOpts

              addCommand "iftocase"
                         "Convert an if statement to a case statement"
                         runCmd
                         ifToCaseCmdOpts

              addCommand "liftOneLevel"
                         "Lift a definition up one level"
                         runCmd
                         liftOneLevelCmdOpts

              addCommand "liftToTopLevel"
                         "Lift a definition to the top level"
                         runCmd
                         liftToTopLevelCmdOpts

              addCommand "rename"
                         "Rename an identifier"
                         runCmd
                         renameCmdOpts

              addCommand "addOneParam"
                         "Add a new parameter to a function in first position"
                         runCmd
                         addOneParamCmdOpts

              addCommand "rmOneParam"
                         "Remove a new parameter from a function"
                         runCmd
                         rmOneParamCmdOpts
    run global

-- ---------------------------------------------------------------------