{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoFieldSelectors  #-}

{-|
Module      : Stack.Types.UpgradeOpts
Description : Types for command line options for Stack's @upgrade@ command.
License     : BSD-3-Clause

Types for command line options for Stack's @upgrade@ command.
-}

module Stack.Types.UpgradeOpts
  ( UpgradeOpts (..)
  , BinaryOpts (..)
  , SourceOpts (..)
  ) where

import           Stack.Prelude

-- | Type representing command line options for the @stack upgrade@ command.

data UpgradeOpts = UpgradeOpts
  { UpgradeOpts -> Maybe BinaryOpts
binary :: !(Maybe BinaryOpts)
  , UpgradeOpts -> Maybe SourceOpts
source :: !(Maybe SourceOpts)
  }
  deriving Int -> UpgradeOpts -> ShowS
[UpgradeOpts] -> ShowS
UpgradeOpts -> String
(Int -> UpgradeOpts -> ShowS)
-> (UpgradeOpts -> String)
-> ([UpgradeOpts] -> ShowS)
-> Show UpgradeOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UpgradeOpts -> ShowS
showsPrec :: Int -> UpgradeOpts -> ShowS
$cshow :: UpgradeOpts -> String
show :: UpgradeOpts -> String
$cshowList :: [UpgradeOpts] -> ShowS
showList :: [UpgradeOpts] -> ShowS
Show

-- | Type representing options for upgrading Stack with a binary executable

-- file.

data BinaryOpts = BinaryOpts
  { BinaryOpts -> Maybe String
platform :: !(Maybe String)
  , BinaryOpts -> Bool
force :: !Bool
    -- ^ Force a download, even if the downloaded version is older than what we

    -- are.

  , BinaryOpts -> Bool
onlyLocalBin :: !Bool
    -- ^ Only download to Stack's local binary directory.

  , BinaryOpts -> Maybe String
version :: !(Maybe String)
    -- ^ Specific version to download

  , BinaryOpts -> Maybe String
gitHubOrg :: !(Maybe String)
  , BinaryOpts -> Maybe String
gitHubRepo :: !(Maybe String)
  }
  deriving Int -> BinaryOpts -> ShowS
[BinaryOpts] -> ShowS
BinaryOpts -> String
(Int -> BinaryOpts -> ShowS)
-> (BinaryOpts -> String)
-> ([BinaryOpts] -> ShowS)
-> Show BinaryOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BinaryOpts -> ShowS
showsPrec :: Int -> BinaryOpts -> ShowS
$cshow :: BinaryOpts -> String
show :: BinaryOpts -> String
$cshowList :: [BinaryOpts] -> ShowS
showList :: [BinaryOpts] -> ShowS
Show

-- | Type representing options for upgrading Stack from source code.

newtype SourceOpts
  = SourceOpts (Maybe (String, String)) -- repo and branch

  deriving Int -> SourceOpts -> ShowS
[SourceOpts] -> ShowS
SourceOpts -> String
(Int -> SourceOpts -> ShowS)
-> (SourceOpts -> String)
-> ([SourceOpts] -> ShowS)
-> Show SourceOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SourceOpts -> ShowS
showsPrec :: Int -> SourceOpts -> ShowS
$cshow :: SourceOpts -> String
show :: SourceOpts -> String
$cshowList :: [SourceOpts] -> ShowS
showList :: [SourceOpts] -> ShowS
Show