-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMessagePrompts.fs
More file actions
27 lines (22 loc) · 1.09 KB
/
MessagePrompts.fs
File metadata and controls
27 lines (22 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module MessagePrompts
let prompt (msg:string) =
System.Console.Write(msg)
System.Console.ReadLine().Trim()
|> function | "" -> None | s -> Some s
|> Option.map (fun s -> s.Replace ("\"","\\\""))
let private isCi () =
match System.Environment.GetEnvironmentVariable "CI" with
| null | "" -> false
| value -> value.Equals("true", System.StringComparison.OrdinalIgnoreCase) || value = "1"
let rec promptYesNo msg =
if isCi () then
System.Console.WriteLine(sprintf "%s [Yn]: (CI env detected, auto-accepting)" msg)
true
else
match prompt (sprintf "%s [Yn]: " msg) with
| Some "Y" | Some "y" -> true
| Some "N" | Some "n" -> false
| _ -> System.Console.WriteLine("Sorry, invalid answer"); promptYesNo msg
let releaseMsg = """This will stage all uncommitted changes, push them to the origin and bump the release version to the latest number in the RELEASE_NOTES.md file.
Do you want to continue?"""
let releaseDocsMsg = """This will push the docs to gh-pages. Remember building the docs prior to this. Do you want to continue?"""