{- |
Copyright: (c) 2020 Kowainik
SPDX-License-Identifier: MPL-2.0
Maintainer: Kowainik <xrom.xkov@gmail.com>

This module introduces different modes in which the command-line interface
could be.
-}

module Summoner.Mode
    ( Interactivity (..)
    , isNonInteractive
    , ConnectMode (..)
    , isOffline
    ) where


-- | Switcher for non-interactive mode.
data Interactivity
    = Interactive
    | NonInteractive
    deriving stock (Int -> Interactivity -> ShowS
[Interactivity] -> ShowS
Interactivity -> String
(Int -> Interactivity -> ShowS)
-> (Interactivity -> String)
-> ([Interactivity] -> ShowS)
-> Show Interactivity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Interactivity] -> ShowS
$cshowList :: [Interactivity] -> ShowS
show :: Interactivity -> String
$cshow :: Interactivity -> String
showsPrec :: Int -> Interactivity -> ShowS
$cshowsPrec :: Int -> Interactivity -> ShowS
Show, Interactivity -> Interactivity -> Bool
(Interactivity -> Interactivity -> Bool)
-> (Interactivity -> Interactivity -> Bool) -> Eq Interactivity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Interactivity -> Interactivity -> Bool
$c/= :: Interactivity -> Interactivity -> Bool
== :: Interactivity -> Interactivity -> Bool
$c== :: Interactivity -> Interactivity -> Bool
Eq)

-- | Is interactivity mode 'NonInteractive'?
isNonInteractive :: Interactivity -> Bool
isNonInteractive :: Interactivity -> Bool
isNonInteractive = \case
    NonInteractive -> Bool
True
    Interactive -> Bool
False

-- | Switcher for offline mode.
data ConnectMode
    = Online
    | Offline
    deriving stock (Int -> ConnectMode -> ShowS
[ConnectMode] -> ShowS
ConnectMode -> String
(Int -> ConnectMode -> ShowS)
-> (ConnectMode -> String)
-> ([ConnectMode] -> ShowS)
-> Show ConnectMode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConnectMode] -> ShowS
$cshowList :: [ConnectMode] -> ShowS
show :: ConnectMode -> String
$cshow :: ConnectMode -> String
showsPrec :: Int -> ConnectMode -> ShowS
$cshowsPrec :: Int -> ConnectMode -> ShowS
Show, ConnectMode -> ConnectMode -> Bool
(ConnectMode -> ConnectMode -> Bool)
-> (ConnectMode -> ConnectMode -> Bool) -> Eq ConnectMode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConnectMode -> ConnectMode -> Bool
$c/= :: ConnectMode -> ConnectMode -> Bool
== :: ConnectMode -> ConnectMode -> Bool
$c== :: ConnectMode -> ConnectMode -> Bool
Eq)

-- | Is connection mode 'Offline'?
isOffline :: ConnectMode -> Bool
isOffline :: ConnectMode -> Bool
isOffline = \case
    Offline -> Bool
True
    Online  -> Bool
False