execParserEnv
    :: Map String String   -- ^ The full environment ENV
    -> [(String, ArgType)] -- ^ The restricted variables to consider within the ENV
    -> ParserInfo a        -- ^ A corresponding CLI
    -> ParserResult a
execParserEnv env vars pInfo = do
    let args = mapMaybe (lookupEnv >=> varToArg) vars
    execParserPure Parser.defaultPrefs pInfo args
  where
    -- | Lookup a value at a given 'Key' in the environment and add it to
    -- the tuple ('Key', 'ArgType')
    lookupEnv :: (String, ArgType) -> Maybe (String, ArgType, String)
    lookupEnv (k, t) =
        (k, t, ) <$> (env ^. at k)

    -- | Convert an environment variable to its argument, with value. Returns
    -- 'Nothing' when Flags are given and turned off. 'Just arg' otherwise.
    varToArg :: (String, ArgType, String) -> Maybe String
    varToArg = \case
        (k, Flag, "True") -> Just ("--" <> sToK k)
        (_, Flag, _)      -> Nothing
        (k, Arg, v)       -> Just ("--" <> sToK k <> "=" <> v)


-- * 'NetworkAddress' manipulations

-- | Get the next 'NetworkAddress' given an index
execParserEnv
    :: Map String String   -- ^ The full environment ENV
    -> [(String, ArgType)] -- ^ The restricted variables to consider within the ENV
    -> ParserInfo a        -- ^ A corresponding CLI
    -> ParserResult a
execParserEnv env vars pInfo = do
    let args = mapMaybe (lookupEnv >=> varToArg) vars
    execParserPure Parser.defaultPrefs pInfo args
  where
    -- | Lookup a value at a given 'Key' in the environment and add it to
    -- the tuple ('Key', 'ArgType')
    lookupEnv :: (String, ArgType) -> Maybe (String, ArgType, String)
    lookupEnv (k, t) =
        (k, t, ) <$> (env ^. at k)

    -- | Convert an environment variable to its argument, with value. Returns
    -- 'Nothing' when Flags are given and turned off. 'Just arg' otherwise.
    varToArg :: (String, ArgType, String) -> Maybe String
    varToArg = \case
        (k, Flag, "True") -> Just ("--" <> sToK k)
        (_, Flag, _)      -> Nothing
        (k, Arg, v)       -> Just ("--" <> sToK k <> "=" <> v)


-- * 'NetworkAddress' manipulations

-- | Get the next 'NetworkAddress' given an index
execParserEnv env vars pInfo = do
    let args = mapMaybe (lookupEnv >=> varToArg) vars
    execParserPure Parser.defaultPrefs pInfo args
  where
    -- | Lookup a value at a given 'Key' in the environment and add it to
    -- the tuple ('Key', 'ArgType')
    lookupEnv :: (String, ArgType) -> Maybe (String, ArgType, String)
    lookupEnv (k, t) =
        (k, t, ) <$> (env ^. at k)

    -- | Convert an environment variable to its argument, with value. Returns
    -- 'Nothing' when Flags are given and turned off. 'Just arg' otherwise.
    varToArg :: (String, ArgType, String) -> Maybe String
    varToArg = \case
        (k, Flag, "True") -> Just ("--" <> sToK k)
        (_, Flag, _)      -> Nothing
        (k, Arg, v)       -> Just ("--" <> sToK k <> "=" <> v)


-- * 'NetworkAddress' manipulations

-- | Get the next 'NetworkAddress' given an index