2021-01-25 18:39:15 +00:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
2020-01-29 00:51:26 +00:00
|
|
|
module Main where
|
|
|
|
|
|
|
|
import Defaults
|
2021-01-25 18:39:15 +00:00
|
|
|
import Defaults.Types (DomainName(..))
|
|
|
|
|
|
|
|
import Options.Applicative
|
2023-06-29 01:34:44 +00:00
|
|
|
import Relude.Extra (un)
|
|
|
|
import Data.Text (unpack)
|
2020-01-29 00:51:26 +00:00
|
|
|
|
|
|
|
-- | Main
|
|
|
|
main :: IO ()
|
|
|
|
main = join $ execParser opts
|
|
|
|
|
|
|
|
-- | App argument parser
|
|
|
|
opts :: ParserInfo (IO ())
|
|
|
|
opts = info
|
|
|
|
(commands <**> helper)
|
2021-01-28 02:22:20 +00:00
|
|
|
(fullDesc <> header "macOS Preferences Manager - a utility for working with macOS preferences.")
|
2020-01-29 00:51:26 +00:00
|
|
|
|
|
|
|
-- | App CLI commands
|
|
|
|
commands :: Parser (IO ())
|
|
|
|
commands = hsubparser
|
2020-08-21 23:33:46 +00:00
|
|
|
( command "watch"
|
|
|
|
(info
|
2021-01-28 02:22:20 +00:00
|
|
|
( watch . fromList <$> some
|
2021-01-25 18:39:15 +00:00
|
|
|
(DomainName <$> strArgument
|
2020-08-21 23:33:46 +00:00
|
|
|
( metavar "DOMAIN..."
|
2023-06-29 01:42:07 +00:00
|
|
|
<> help "Domain(s) that will be watched"
|
2023-06-29 01:34:44 +00:00
|
|
|
<> completer domainCompleter
|
2020-08-21 23:33:46 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
<|> flag' (watch =<< domains)
|
|
|
|
( long "all"
|
|
|
|
<> short 'a'
|
2023-06-29 01:42:07 +00:00
|
|
|
<> help "Watch all domains including NSGlobalDomain"
|
2020-08-21 23:33:46 +00:00
|
|
|
)
|
|
|
|
)
|
2023-06-29 01:42:07 +00:00
|
|
|
$ progDesc "Watch domain(s) for changes"
|
2020-08-21 23:33:46 +00:00
|
|
|
)
|
2021-01-25 18:47:51 +00:00
|
|
|
<> command "domains"
|
2020-08-21 23:33:46 +00:00
|
|
|
(info
|
2021-01-28 02:22:20 +00:00
|
|
|
(pure printDomains)
|
2023-06-29 01:42:07 +00:00
|
|
|
(progDesc "List all domains")
|
2021-01-28 02:22:20 +00:00
|
|
|
)
|
|
|
|
<> command "keys"
|
|
|
|
(info
|
|
|
|
(printKeys . DomainName <$> strArgument
|
|
|
|
( metavar "DOMAIN"
|
2023-06-29 01:42:07 +00:00
|
|
|
<> help "A domain for which to list keys"
|
2023-06-29 01:34:44 +00:00
|
|
|
<> completer domainCompleter
|
2021-01-28 02:22:20 +00:00
|
|
|
)
|
|
|
|
)
|
2023-06-29 01:42:07 +00:00
|
|
|
$ progDesc "List the current keys in a domain"
|
2020-08-21 23:33:46 +00:00
|
|
|
)
|
2020-01-29 00:51:26 +00:00
|
|
|
)
|
2023-06-29 01:34:44 +00:00
|
|
|
where
|
|
|
|
domainCompleter = listIOCompleter $ fmap (fmap unpack . un . toList) domains
|