-
Notifications
You must be signed in to change notification settings - Fork 263
Expand file tree
/
Copy pathProgram.cs
More file actions
30 lines (22 loc) · 856 Bytes
/
Program.cs
File metadata and controls
30 lines (22 loc) · 856 Bytes
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
// 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 System.Threading.Tasks;
using McMaster.Extensions.CommandLineUtils;
var app = new CommandLineApplication();
app.HelpOption();
var subject = app.Option("-s|--subject <SUBJECT>", "The subject", CommandOptionType.SingleValue);
subject.DefaultValue = "world";
var repeat = app.Option<int>("-n|--count <N>", "Repeat", CommandOptionType.SingleValue);
repeat.DefaultValue = 1;
app.OnExecuteAsync(async cancellationToken =>
{
for (var i = 0; i < repeat.ParsedValue; i++)
{
Console.Write($"Hello");
// Pause for dramatic effect
await Task.Delay(2000, cancellationToken);
Console.WriteLine($" {subject.Value()}!");
}
});
return app.Execute(args);