{-# LANGUAGE ApplicativeDo #-}
{-# LANGUAGE RecordWildCards #-}
module PFile.CLI.Unpack
( parserInfo
, parser
, Options (..)
) where
import Options.Applicative
( Parser
, ParserInfo
, fullDesc
, header
, help
, helper
, info
, long
, progDesc
, short
, switch
)
import Protolude
parserInfo :: ParserInfo Options
parserInfo :: ParserInfo Options
parserInfo = Parser Options -> InfoMod Options -> ParserInfo Options
forall a. Parser a -> InfoMod a -> ParserInfo a
info (Parser Options
parser Parser Options -> Parser (Options -> Options) -> Parser Options
forall (f :: * -> *) a b. Applicative f => f a -> f (a -> b) -> f b
<**> Parser (Options -> Options)
forall a. Parser (a -> a)
helper)
(InfoMod Options -> ParserInfo Options)
-> InfoMod Options -> ParserInfo Options
forall a b. (a -> b) -> a -> b
$ InfoMod Options
forall a. InfoMod a
fullDesc
InfoMod Options -> InfoMod Options -> InfoMod Options
forall a. Semigroup a => a -> a -> a
<> String -> InfoMod Options
forall a. String -> InfoMod a
header String
"pfile unpack - revert `pfile new` and `pfile switch`"
InfoMod Options -> InfoMod Options -> InfoMod Options
forall a. Semigroup a => a -> a -> a
<> String -> InfoMod Options
forall a. String -> InfoMod a
progDesc String
description
where
description :: String
description
= String
"Substitute links pointing at entries in the current profile with"
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" entries themselves. This substitution \"reverts\" `pfile switch`"
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" (removes links & unsets current profile) and `pfile new` (unpacks"
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" entries from profile). `pfile unpack` will not change the profile --"
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" entries that were added to the profile will remain unchanged. `pfile"
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" unpack` could be reverted with `pfile switch -f PROFILE`."
parser :: Parser Options
parser :: Parser Options
parser = do
Bool
forceRemoveOccupied <- Mod FlagFields Bool -> Parser Bool
switch
(Mod FlagFields Bool -> Parser Bool)
-> Mod FlagFields Bool -> Parser Bool
forall a b. (a -> b) -> a -> b
$ Char -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => Char -> Mod f a
short Char
'f'
Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"force-remove-occupied"
Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields Bool
forall (f :: * -> *) a. String -> Mod f a
help String
"Force remove of paths occupying current profile's link paths"
pure Options {Bool
forceRemoveOccupied :: Bool
forceRemoveOccupied :: Bool
..}
newtype Options
= Options { Options -> Bool
forceRemoveOccupied :: Bool }