1
0
Fork 0
mirror of https://github.com/malob/prefmanager.git synced 2024-12-14 11:57:49 +00:00
prefmanager/app/Main.hs

59 lines
1.5 KiB
Haskell
Raw Permalink Normal View History

{-# LANGUAGE OverloadedStrings #-}
2020-01-29 00:51:26 +00:00
module Main where
import Defaults
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)
(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
( watch . fromList <$> some
(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
(pure printDomains)
2023-06-29 01:42:07 +00:00
(progDesc "List all domains")
)
<> 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
)
)
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