summarylogtreecommitdiffstats
path: root/Commands.cs
blob: e82a890fa106ccd74083e7e0f4f9aad85a22fafb (plain)
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
using System.Text.RegularExpressions;
using CommandLine;

namespace rgx;

internal interface ICmd
{
    [Value(0, MetaName = "pattern", Required = true)]
    public string pattern { get; set; }

    [Option('x', "options", Separator = ',', Required = false)]
    public IEnumerable<RegexOptions> options { get; set; }

    [Option('i', "input", Required = false, Default = null)]
    public string? input { get; set; }

    [Option('o', "output", Required = false, Default = null)]
    public string? output { get; set; }
}

[Verb("-M", true, new[] { "-R" })]
internal class MatchAndReplace : ICmd
{
    [Option('d', "default", Required = false, Default = null)]
    public bool useDefault { get; set; }

    [Value(1, MetaName = "replacement", Required = false, Default = null)]
    public string? replacement { get; set; }

    public string pattern { get; set; }
    public IEnumerable<RegexOptions> options { get; set; }
    public string? input { get; set; }
    public string? output { get; set; }
}

[Verb("-S")]
internal class Split : ICmd
{
    public string pattern { get; set; }
    public IEnumerable<RegexOptions> options { get; set; }
    public string? input { get; set; }
    public string? output { get; set; }
}