-
Notifications
You must be signed in to change notification settings - Fork 261
Expand file tree
/
Copy pathProgram.cs
More file actions
25 lines (22 loc) · 898 Bytes
/
Copy pathProgram.cs
File metadata and controls
25 lines (22 loc) · 898 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
// 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;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
class Program
{
static Task<int> Main(string[] args)
=> new HostBuilder()
.RunCommandLineApplicationAsync(args, (app) =>
{
var portOption = app.Option<int>("-p|--port <PORT>", "Port", CommandOptionType.SingleValue);
app.OnExecute(() =>
{
var port = portOption.HasValue() ? portOption.ParsedValue : 8080;
var env = app.GetRequiredService<IHostEnvironment>();
Console.WriteLine($"Starting on port {port}, env = {env.EnvironmentName}");
});
});
}