-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
36 lines (33 loc) · 1.05 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
using System;
using System.Collections.Generic;
using App.data;
namespace App {
class Program {
// static method
/// <summary>
/// When in doubt, flee.
/// : Unggoy philosophy.
/// </summary>
/// <param name="args">Input arguments.</param>
static void Main(string[] args) {
Params p = DefParams(new Params(args));
List<string> li = ListAct.New(p.Input, p.InpSep.ToArray());
ListAct.Sep = p.ArgSep.ToArray();
IList<string> lo = ListAct.Fn.ContainsKey(p.Fn) ? ListAct.Fn[p.Fn](li, p.Args.ToArray()) : li;
Console.WriteLine(ListAct.ToString(lo, p.OutSep[0]));
}
/// <summary>
/// Set default values for parameters if not specified.
/// </summary>
/// <param name="p">Parameters.</param>
private static Params DefParams(Params p) {
List<string> sep = new List<string>(ListAct.DefSep);
if (p.Input == null) p.Input = Console.In.ReadToEnd();
if (p.InpSep.Count == 0) p.InpSep = sep;
if (p.ArgSep.Count == 0) p.ArgSep = sep;
if (p.OutSep.Count == 0) p.OutSep = sep;
if (p.Fn == null) p.Fn = "";
return p;
}
}
}