summaryrefslogtreecommitdiff
path: root/CommandLineWrapper/Constants.cs
blob: 91d0bd8c85468e72ab327bd4eefbe434be17f43c (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
namespace CommandLineWrapper;

public static class Constants
{
    // Command line program path
    public static FileInfo CommandLinePath => new FileInfo(
        Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
            OperatingSystem.IsWindows() ? "JustEnoughVCS.exe" : "JustEnoughVCS")
    );

    public static class CommandParameterGenerator
    {
        // Workspace Creation
        public static string[] Initialize() => ["init"];
        public static string[] Create(string name) => ["create", name];

        // Upstream Binding
        public static string[] Login(string account, string upstream) => ["login", account, upstream, "-C"];
        public static string[] Direct(string upstream) => ["direct", upstream, "-C"];
        public static string[] Unstain() => ["unstain", "-C"];
        public static string[] Update() => ["update"];

        // Account Management
        public static string[] AccountAs(string account) => ["account", "as", account];
        public static string[] AccountAdd(string account) => ["account", "add", account];
        public static string[] AccountAddWithKey(string account) => ["account", "add", account, "--keygen"];
        public static string[] AccountMoveKey(string account, FileInfo privateKey) => ["account", "movekey", account, privateKey.ToString()];
        public static string[] AccountRemove(string account) => ["account", "remove", account];
        public static string[] AccountGeneratePublicKey(string account, DirectoryInfo directory)
            => ["account", "genpub", account, directory.ToString()];

        // Sheet Management
        public static string[] SheetUse(string sheet) => ["sheet", "use", sheet];
        public static string[] SheetExit() => ["sheet", "exit"];
        public static string[] SheetSwitch(string sheet) => ["use", sheet];
        public static string[] SheetMake(string sheet) => ["sheet", "make", sheet, "-C"];
        public static string[] SheetDrop(string sheet) => ["sheet", "drop", sheet, "-C"];
        public static string[] SheetAlignOperation(string operationA, string operationB) => ["sheet", "align", operationA, operationB];

        // Share
        public static string[] Share(string mappingPattern, string sheet, string description) => ["share", mappingPattern, sheet, description];
        public static string[] ShareImportSafeMode(string shareId) => ["share", shareId, "--safe"];
        public static string[] ShareImportSkipMode(string shareId) => ["share", shareId, "--skip"];
        public static string[] ShareImportOverwriteMode(string shareId) => ["share", shareId, "--overwrite"];
        public static string[] ShareReject(string shareId) => ["share", shareId, "--reject"];

        // File Operations
        public static string[] Track(string mappingPattern) => ["track", mappingPattern];
        public static string[] TrackWithUpdate(string mappingPattern, string nextVersion, string description)
            => ["track", mappingPattern, "--version", nextVersion, "--desc", description];
        public static string[] TrackAndOverwrite(string mappingPattern)
            => ["track", mappingPattern, "--overwrite"];
        public static string[] Hold(string mappingPattern) => ["hold", mappingPattern];
        public static string[] Throw(string mappingPattern) => ["throw", mappingPattern];
        public static string[] TryHold(string mappingPattern) => ["hold", mappingPattern, "--skip-failed"];
        public static string[] TryThrow(string mappingPattern) => ["throw", mappingPattern, "--skip-failed"];
        public static string[] HoldUnchecked(string mappingPattern) => ["hold", mappingPattern, "--force"];
        public static string[] ThrowUnchecked(string mappingPattern) => ["throw", mappingPattern, "--force"];

        // Informations
        public static string[] Here() => ["here", "--json"];
        public static string[] Status() => ["status", "--json"];
        public static string[] Info(string mappingName) => ["info", mappingName, "--json"];
        public static string[] AccountList() => ["account", "list", "--json"];
        public static string[] SheetList() => ["sheet", "list", "--json"];
        public static string[] SheetAlignList() => ["sheet", "align", "--json"];
        public static string[] ShareList() => ["share", "list", "--json"];
        public static string[] ShareSee(string shareId) => ["share", "see", shareId, "--json"];
        public static string[] GetWorkspaceDirectory() => ["_workspace_dir"];
        public static string[] GetCurrentAccount() => ["_account"];
        public static string[] GetCurrentUpstream() => ["_upstream"];
        public static string[] GetCurrentSheet() => ["_sheet"];
    }
}