Print a warning when --site-url is set but none of --open-graph-cards or --rss is set
This commit is contained in:
parent
18d0e73062
commit
bc861e3eeb
1 changed files with 9 additions and 2 deletions
|
@ -11,6 +11,7 @@ import qualified Arguments as Arguments (Arguments(..))
|
|||
import Data.Aeson (ToJSON(..), (.=), pairs)
|
||||
import GHC.Generics (Generic)
|
||||
import System.Exit (die)
|
||||
import System.IO (hPutStrLn, stderr)
|
||||
import Text.Printf (printf)
|
||||
|
||||
data URL = URL {
|
||||
|
@ -26,13 +27,19 @@ instance ToJSON URL where
|
|||
|
||||
build :: Arguments -> IO URL
|
||||
build arguments = do
|
||||
cards <- getSiteURL (Arguments.openGraphCards arguments) "Open Graph cards"
|
||||
rss <- getSiteURL (Arguments.rss arguments) "RSS feeds"
|
||||
cards <- getSiteURL argOGCards "Open Graph cards"
|
||||
rss <- getSiteURL argRSS "RSS feeds"
|
||||
checksUsed (argOGCards || argRSS) siteURL
|
||||
return $ URL {cards, comments, rss}
|
||||
where
|
||||
comments = Arguments.commentsURL arguments
|
||||
siteURL = Arguments.siteURL arguments
|
||||
argOGCards = Arguments.openGraphCards arguments
|
||||
argRSS = Arguments.rss arguments
|
||||
errorMsg :: String -> String
|
||||
errorMsg = printf "Enabling %s requires setting the site url with --site-url"
|
||||
getSiteURL False _ = return Nothing
|
||||
getSiteURL True name = maybe (die $ errorMsg name) (return . Just) siteURL
|
||||
checksUsed False (Just _) =
|
||||
hPutStrLn stderr "Site url is set but not used, did you forget --open-graph-cards or --rss ?"
|
||||
checksUsed _ _ = return ()
|
||||
|
|
Loading…
Reference in a new issue