-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
44 lines (35 loc) · 1.4 KB
/
Copy pathProgram.cs
File metadata and controls
44 lines (35 loc) · 1.4 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System.CommandLine;
using Hypr.Configuration;
using Hypr.Logging;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Hypr;
// Build configuration with proper precedence order
var configBuilder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile(PathProvider.GetGlobalConfigPath(), optional: true, reloadOnChange: true)
.AddJsonFile("hypr.json", optional: true, reloadOnChange: true)
.AddJsonFile(".hypr.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables("HYPR_");
var configuration = configBuilder.Build();
var builder = Host.CreateApplicationBuilder(args);
builder.Configuration.AddConfiguration(configuration);
// Add Hypr logging with debug flag support
builder.Services.AddHyprLogging(args);
// Register configuration
builder.Services.AddSingleton<IConfiguration>(configuration);
// Register services, configuration sections, and commands
builder.Services.AddServices(builder.Configuration);
var host = builder.Build();
var rootCommand = new RootCommand("hypr - Git worktree manager");
rootCommand.Options.Add(new DebugOption());
var commands = host.Services.GetRequiredService<IEnumerable<Command>>();
foreach (var cmd in commands)
{
rootCommand.Subcommands.Add(cmd);
}
// Parse and invoke
return await rootCommand
.Parse(args)
.InvokeAsync();