@@ -2,7 +2,7 @@ module Main where
2
2
3
3
import Control.Monad (forM , forM_ )
4
4
import Data.Char (isLower , isSpace , toLower , toUpper )
5
- import System.Directory (createDirectory )
5
+ import System.Directory (createDirectory , createDirectoryIfMissing )
6
6
import System.FilePath ((<.>) , (</>) )
7
7
import System.IO (BufferMode (.. ), hSetBuffering , stdout )
8
8
import Text.Read (readMaybe )
@@ -31,7 +31,7 @@ data Tool = GHC | GHCup | Stack deriving (Show)
31
31
32
32
readTool :: IO Tool
33
33
readTool = do
34
- putStrLn " Which tool's error code do you want to document?"
34
+ putStrLn " · Which tool's error code do you want to document?"
35
35
putStrLn " 1) GHC"
36
36
putStrLn " 2) GHCup"
37
37
putStrLn " 3) Stack"
@@ -57,7 +57,7 @@ type ErrorCode = String
57
57
58
58
readCode :: IO ErrorCode
59
59
readCode = do
60
- putStrLn " What is the numeric code that you want to document. "
60
+ putStrLn " · What is the numeric code that you want to document? "
61
61
putStrLn " For example, enter \" 01234\" if you want to document GHC-01234."
62
62
putStr " Input: "
63
63
ln <- getLine
@@ -72,7 +72,7 @@ type Title = String
72
72
73
73
readTitle :: IO Title
74
74
readTitle = do
75
- putStrLn " What is the title of the error message?"
75
+ putStrLn " · What is the title of the error message?"
76
76
putStrLn " This is used as the title of the documentation page as well as in links to the page."
77
77
putStr " Input: "
78
78
getLine
@@ -82,7 +82,7 @@ type Summary = String
82
82
83
83
readSummary :: IO Summary
84
84
readSummary = do
85
- putStrLn " Give a short summary of the error message."
85
+ putStrLn " · Give a short summary of the error message."
86
86
putStrLn " This appears on the overview page that lists all the documented errors and warnings."
87
87
putStr " Input: "
88
88
getLine
@@ -92,7 +92,7 @@ data Severity = Error | Warning deriving (Show)
92
92
93
93
readSeverity :: IO Severity
94
94
readSeverity = do
95
- putStrLn " What is the severity of the diagnostic. "
95
+ putStrLn " · What is the severity of the diagnostic? "
96
96
putStrLn " 1) Error"
97
97
putStrLn " 2) Warning"
98
98
putStr " Input (Default = Error): "
@@ -113,7 +113,7 @@ type WarningFlag = String
113
113
-- | Only ask for a warning flag if Severity = Warning.
114
114
readWarningFlag :: Severity -> IO (Maybe WarningFlag )
115
115
readWarningFlag Warning = do
116
- putStrLn " What is the warning flag which enables this warning?"
116
+ putStrLn " · What is the warning flag which enables this warning?"
117
117
putStrLn " For example, enter \" -Wtabs\" if you are documenting GHC's warning about tabs in your source file."
118
118
putStrLn " You can leave this blank if you're not sure."
119
119
putStr " Input: "
@@ -125,7 +125,7 @@ type Version = String
125
125
126
126
readVersion :: IO Version
127
127
readVersion = do
128
- putStrLn " Which version of the tool emitted the numeric code (not the message) for the first time?"
128
+ putStrLn " · Which version of the tool emitted the numeric code (not the message) for the first time?"
129
129
putStrLn " Note: For GHC this is most likely 9.6.1."
130
130
putStr " Input: "
131
131
getLine
@@ -140,7 +140,7 @@ validateExampleName str@(s : _) = not (any isSpace str) && isLower s
140
140
-- | Only ask for examples if the system is GHC.
141
141
readExamples :: Tool -> IO Examples
142
142
readExamples GHC = do
143
- putStrLn " How many examples should be generated?"
143
+ putStrLn " · How many examples should be generated?"
144
144
putStr " Input: "
145
145
ln <- getLine
146
146
case readMaybe ln :: Maybe Int of
@@ -150,7 +150,8 @@ readExamples _ = pure []
150
150
151
151
readExample :: Int -> IO String
152
152
readExample i = do
153
- putStrLn (" Give a name for example " <> show i)
153
+ putStrLn " "
154
+ putStrLn (" · Give a name for example " <> show i)
154
155
putStrLn " The name should not contain spaces and begin with a lowercase letter."
155
156
putStr " Input: "
156
157
ln <- getLine
@@ -197,13 +198,13 @@ readTemplate = do
197
198
198
199
createFiles :: Template -> IO ()
199
200
createFiles tmpl = do
200
- putStrLn " Creating scaffolding for the following configuration:"
201
- print tmpl
202
201
putStrLn " "
202
+ putStrLn " · Creating scaffolding..."
203
203
204
204
-- Create the new directory "messages/XXX-NNNNNN/" and "messages/XXX-NNNNNN/index.md"
205
205
let message_dir = " messages" </> case tool tmpl of { GHC -> " GHC-" ; GHCup -> " GHCup-" ; Stack -> " S-" } ++ code tmpl
206
- createDirectory message_dir
206
+ createDirectoryIfMissing True message_dir
207
+ let index_filename = message_dir </> " index.md"
207
208
let toplvl_index =
208
209
unlines
209
210
[ " ---" ,
@@ -215,7 +216,10 @@ createFiles tmpl = do
215
216
" " ,
216
217
" Insert your error message here."
217
218
]
218
- writeFile (message_dir </> " index.md" ) toplvl_index
219
+ writeFile index_filename toplvl_index
220
+ putStrLn (" ·· Created file " <> index_filename <> " with these contents:" )
221
+ putStrLn " "
222
+ putStr toplvl_index
219
223
220
224
-- Create the example directories and entries:
221
225
-- - "messages/XXX-NNNNNN/" and "messages/XXX-NNNNNN/example-name/index.md"
@@ -227,6 +231,7 @@ createFiles tmpl = do
227
231
uppercase (s : ss) = toUpper s : ss
228
232
let example_name = uppercase example
229
233
createDirectory example_dir
234
+ putStrLn (" ·· Creating blank example in directory " <> example_dir <> " ..." )
230
235
createDirectory (example_dir </> " before" )
231
236
createDirectory (example_dir </> " after" )
232
237
let example_index =
0 commit comments