-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
58 lines (49 loc) · 1.68 KB
/
Program.cs
File metadata and controls
58 lines (49 loc) · 1.68 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using MultiRepositories;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using CommandLine;
using Newtonsoft.Json;
namespace RepositoryCache
{
class Program
{
static void Main(string[] args)
{
var options = new Options();
Parser.Default.ParseArguments<Options>(args)
.WithParsed<Options>(opts => RunOptionsAndReturnExitCode(opts))
.WithNotParsed<Options>((errs) => HandleParseError(errs));
}
private static void HandleParseError(IEnumerable<Error> errs)
{
}
private static void RunOptionsAndReturnExitCode(Options opts)
{
var settingsFile = opts.Settings;
if (!string.IsNullOrWhiteSpace(settingsFile) && File.Exists(settingsFile))
{
Console.WriteLine("Reading settings from " + settingsFile);
opts = JsonConvert.DeserializeObject<Options>(File.ReadAllText(settingsFile));
}
if (string.IsNullOrWhiteSpace(opts.Path))
{
opts.Path = Directory.GetCurrentDirectory();
}
opts.Settings = settingsFile;
var settings = JsonConvert.SerializeObject(opts);
Console.WriteLine(settings);
var shhtp = new SimpleHTTPServer(opts.Path, opts.Port,opts.LogRequests,opts.Urls,opts.Ignores);
while (Console.ReadKey().KeyChar != 'q')
{
Console.WriteLine("");
continue;
}
shhtp.Stop();
}
}
}