finalOpt is the same as optional
This commit is contained in:
parent
463709ab2a
commit
d8d1499229
3 changed files with 4 additions and 10 deletions
|
@ -84,7 +84,7 @@ parseUnusedKeysOption = switch
|
||||||
)
|
)
|
||||||
|
|
||||||
parseSpecificKeyOption :: Parser (Maybe Key)
|
parseSpecificKeyOption :: Parser (Maybe Key)
|
||||||
parseSpecificKeyOption = finalOpt $ option (str >>= parseKey)
|
parseSpecificKeyOption = optional $ option (str >>= parseKey)
|
||||||
( long "key"
|
( long "key"
|
||||||
<> help "operate on specified key"
|
<> help "operate on specified key"
|
||||||
<> metavar paramKey
|
<> metavar paramKey
|
||||||
|
@ -201,9 +201,3 @@ parseAutoOption = switch
|
||||||
{- Parser that accepts all non-option params. -}
|
{- Parser that accepts all non-option params. -}
|
||||||
cmdParams :: CmdParamsDesc -> Parser CmdParams
|
cmdParams :: CmdParamsDesc -> Parser CmdParams
|
||||||
cmdParams paramdesc = many (argument str (metavar paramdesc))
|
cmdParams paramdesc = many (argument str (metavar paramdesc))
|
||||||
|
|
||||||
{- Makes an option parser that is normally required be optional;
|
|
||||||
- - its switch can be given zero or more times, and the last one
|
|
||||||
- - given will be used. -}
|
|
||||||
finalOpt :: Parser a -> Parser (Maybe a)
|
|
||||||
finalOpt = lastMaybe <$$> many
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ optParser desc = DropOptions
|
||||||
<*> parseKeyOptions False
|
<*> parseKeyOptions False
|
||||||
|
|
||||||
parseDropFromOption :: Parser (Maybe RemoteName)
|
parseDropFromOption :: Parser (Maybe RemoteName)
|
||||||
parseDropFromOption = finalOpt $ strOption
|
parseDropFromOption = optional $ strOption
|
||||||
( long "from"
|
( long "from"
|
||||||
<> short 'f'
|
<> short 'f'
|
||||||
<> metavar paramRemote
|
<> metavar paramRemote
|
||||||
|
|
|
@ -59,7 +59,7 @@ data FsckOptions = FsckOptions
|
||||||
optParser :: CmdParamsDesc -> Parser FsckOptions
|
optParser :: CmdParamsDesc -> Parser FsckOptions
|
||||||
optParser desc = FsckOptions
|
optParser desc = FsckOptions
|
||||||
<$> cmdParams desc
|
<$> cmdParams desc
|
||||||
<*> finalOpt (strOption
|
<*> optional (strOption
|
||||||
( long "from"
|
( long "from"
|
||||||
<> short 'f'
|
<> short 'f'
|
||||||
<> metavar paramRemote
|
<> metavar paramRemote
|
||||||
|
@ -75,7 +75,7 @@ optParser desc = FsckOptions
|
||||||
<> short 'm'
|
<> short 'm'
|
||||||
<> help "continue an incremental fsck"
|
<> help "continue an incremental fsck"
|
||||||
)
|
)
|
||||||
<*> finalOpt (option (str >>= parseDuration)
|
<*> optional (option (str >>= parseDuration)
|
||||||
( long "incremental-schedule"
|
( long "incremental-schedule"
|
||||||
<> metavar paramTime
|
<> metavar paramTime
|
||||||
<> help "schedule incremental fscking"
|
<> help "schedule incremental fscking"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue