Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deprecation messages #368

Merged
merged 1 commit into from
Nov 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions summoner-cli/src/Summoner/Project.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import Summoner.Question (YesNoPrompt (..), checkUniqueName, choose, falseMessag
targetMessageWithText, trueMessage)
import Summoner.Settings (Settings (..))
import Summoner.Shell (createFileWithParents)
import Summoner.Source (fetchSource)
import Summoner.Source (Source, fetchSource)
import Summoner.Template (createProjectTemplate)
import Summoner.Text (intercalateMap, packageToModule)
import Summoner.Tree (showBoldTree, traverseTree)
Expand Down Expand Up @@ -114,9 +114,16 @@ generateProject isOffline projectName Config{..} = do
when (oldGhcIncluded && settingsStack && settingsTravis) $
warningMessage "Old GHC versions won't be included into Stack matrix at Travis CI because of the Stack issue with newer Cabal versions."

let fetchLast = maybe (pure Nothing) (fetchSource isOffline) . getLast
settingsStylish <- fetchLast cStylish
settingsContributing <- fetchLast cContributing
let fetchLast :: Text -> Last Source -> IO (Maybe Text)
fetchLast option (Last mSource) = case mSource of
Nothing -> pure Nothing
Just source -> do
let msg = [text|The option '${option}' is deprecated. Use 'files' instead.|]
warningMessage msg
fetchSource isOffline source

settingsStylish <- fetchLast "stylish.{url,file,link}" cStylish
settingsContributing <- fetchLast "contributing.{url,file,link}" cContributing
let settingsFiles = cFiles

-- Create project data from all variables in scope
Expand Down
14 changes: 13 additions & 1 deletion summoner-tui/src/Summoner/Tui.hs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ drawNew dirs kitForm = case kit ^. shouldSummon of
[ informationBlock
, validationBlock
, configBlock
, deprecationBlock
, fill ' '
]
where
Expand All @@ -240,6 +241,9 @@ drawNew dirs kitForm = case kit ^. shouldSummon of
infoTxt :: Text -> Widget SummonForm
infoTxt = withAttr "blue-fg" . txtWrap . (<>) " ⓘ "

deprecationTxt :: Text -> Widget SummonForm
deprecationTxt = withAttr "yellow-fg" . txtWrap . (<>) " ⚠ "

validationBlock :: Widget SummonForm
validationBlock = vBox $ case formErrorMessages dirs kitForm of
[] -> [withAttr "green-fg" $ str " ✔ Project configuration is valid"]
Expand All @@ -250,6 +254,13 @@ drawNew dirs kitForm = case kit ^. shouldSummon of
Nothing -> emptyWidget
Just file -> infoTxt $ toText file <> " file is used"

deprecationBlock :: Widget SummonForm
deprecationBlock = case (kit ^. stylish, kit ^. contributing) of
(Nothing, Nothing) -> emptyWidget
(s, c) -> vBox $
[ deprecationTxt "Option 'stylish' is deprecated, use 'files'" | isJust s ]
++ [ deprecationTxt "Option 'contributing' is deprecated, use 'files'" | isJust c]

help, helpBody :: Widget SummonForm
help = borderLabel "Help" (helpBody <+> fill ' ')
helpBody = vBox
Expand Down Expand Up @@ -353,11 +364,12 @@ theMap = attrMap V.defAttr
, (editFocusedAttr, V.black `Brick.on` V.white)
, (invalidFormInputAttr, V.white `Brick.on` V.red)
, (focusedFormInputAttr, V.black `Brick.on` V.yellow)
, (listSelectedAttr, V.black `Brick.on` V.cyan)
, (listSelectedAttr, V.black `Brick.on` V.cyan)
, (listSelectedFocusedAttr, V.black `Brick.on` V.white)
, (disabledAttr, fg V.brightBlack)
, ("blue-fg", fg V.blue)
, ("green-fg", fg V.green)
, ("yellow-fg", fg V.yellow)
, ("red-fg", fg V.brightRed)
, (borderAttr, fg V.cyan)
, ("tree", fg V.cyan)
Expand Down