-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
executable file
·39 lines (36 loc) · 1.51 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
using System;
using cit.utilities;
using cit.tasks;
using System.Collections.Generic;
using cit.cli;
namespace cit
{
public class Program
{
public static int Main(string[] args)
{
if (args.Length == 0)
{
Console.WriteLine($"Welcome to CIt. Version: {Constants.Version}");
}
return GetTaskFor(args[0], new Parser(Console.WriteLine)).Invoke(args);
}
private static Func<string[], int> GetTaskFor(string command, Parser parser)
{
var tasks = new Dictionary<string, Func<string[], int>>
{
{"init", (args) => new InitTask(Console.WriteLine).HandleCommand(parser.TryInitCommand(args))},
{"clean", (args) => new CleanTask(Console.WriteLine).HandleCommand(parser.TryCleanCommand(args))},
{"add", (args) => new AddTask(Console.WriteLine).HandleCommand(parser.TryAddCommand(args))},
{"apply", (args) => new ApplyTask(Console.WriteLine).HandleCommand(parser.TryApplyCommand(args))},
{"remove", (args) => new RemoveTask(Console.WriteLine).HandleCommand(parser.TryRemoveCommand(args))},
{"copy", (args) => new CopyTask(Console.WriteLine).HandleCommand(parser.TryCopyCommand(args))}
};
if(tasks.ContainsKey(command))
{
return tasks[command];
}
return (args) => new HelpTask(Console.WriteLine).HandleCommand(args);
}
}
}