-
-
Notifications
You must be signed in to change notification settings - Fork 259
/
Program.cs
49 lines (41 loc) · 1.76 KB
/
Program.cs
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (c) Nate McMaster.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using McMaster.Extensions.CommandLineUtils;
class Program
{
static void Main(string[] args)
{
var proceed = Prompt.GetYesNo("Do you want to proceed with this demo?",
defaultAnswer: true,
promptColor: ConsoleColor.Black,
promptBgColor: ConsoleColor.White);
if (!proceed) return;
var name = Prompt.GetString("What is your name?",
promptColor: ConsoleColor.White,
promptBgColor: ConsoleColor.DarkGreen);
Console.WriteLine($"Hello, there { name ?? "anonymous console user"}.");
var age = Prompt.GetInt("How old are you?",
promptColor: ConsoleColor.White,
promptBgColor: ConsoleColor.DarkRed);
var password = Prompt.GetPassword("What is your password?",
promptColor: ConsoleColor.White,
promptBgColor: ConsoleColor.DarkBlue);
Console.Write($"Your password contains {password.Length} characters. ");
switch (password.Length)
{
case int _ when (password.Length < 2):
Console.WriteLine("Your password is so short you might as well not have one.");
break;
case int _ when (password.Length < 4):
Console.WriteLine("Your password is too short. You should pick a better one");
break;
case int _ when (password.Length < 10):
Console.WriteLine("Your password is too okay, I guess.");
break;
default:
Console.WriteLine("Your password is probably adequate.");
break;
}
}
}