mirror of
https://github.com/malob/prefmanager.git
synced 2024-12-14 11:57:49 +00:00
52 lines
1.3 KiB
Haskell
52 lines
1.3 KiB
Haskell
{-# LANGUAGE OverloadedStrings #-}
|
|
module Main where
|
|
|
|
import Defaults
|
|
import Defaults.Types (DomainName(..))
|
|
|
|
import Options.Applicative
|
|
|
|
-- | Main
|
|
main :: IO ()
|
|
main = join $ execParser opts
|
|
|
|
-- | App argument parser
|
|
opts :: ParserInfo (IO ())
|
|
opts = info
|
|
(commands <**> helper)
|
|
(fullDesc <> header "macOS Preferences Manager - a utility for working with macOS preferences.")
|
|
|
|
-- | App CLI commands
|
|
commands :: Parser (IO ())
|
|
commands = hsubparser
|
|
( command "watch"
|
|
(info
|
|
( watch . fromList <$> some
|
|
(DomainName <$> strArgument
|
|
( metavar "DOMAIN..."
|
|
<> help "Domain(s) that will be watched."
|
|
)
|
|
)
|
|
<|> flag' (watch =<< domains)
|
|
( long "all"
|
|
<> short 'a'
|
|
<> help "Watch all domains including NSGlobalDomain."
|
|
)
|
|
)
|
|
$ progDesc "Watch domain(s) for changes."
|
|
)
|
|
<> command "domains"
|
|
(info
|
|
(pure printDomains)
|
|
(progDesc "List all domains.")
|
|
)
|
|
<> command "keys"
|
|
(info
|
|
(printKeys . DomainName <$> strArgument
|
|
( metavar "DOMAIN"
|
|
<> help "A domain for which to list keys."
|
|
)
|
|
)
|
|
$ progDesc "List the current keys in a domain."
|
|
)
|
|
)
|