summaryrefslogtreecommitdiff
path: root/src/MtsIoSysfs.cpp
blob: 390db47296c9208316ef10b841726e15e843d65f (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
75
/**********************************************************************
* COPYRIGHT 2020 MULTI-TECH SYSTEMS, INC.
*
* ALL RIGHTS RESERVED BY AND FOR THE EXCLUSIVE BENEFIT OF
* MULTI-TECH SYSTEMS, INC.
*
* MULTI-TECH SYSTEMS, INC. - CONFIDENTIAL AND PROPRIETARY
* INFORMATION AND/OR TRADE SECRET.
*
* NOTICE: ALL CODE, PROGRAM, INFORMATION, SCRIPT, INSTRUCTION,
* DATA, AND COMMENT HEREIN IS AND SHALL REMAIN THE CONFIDENTIAL
* INFORMATION AND PROPERTY OF MULTI-TECH SYSTEMS, INC.
* USE AND DISCLOSURE THEREOF, EXCEPT AS STRICTLY AUTHORIZED IN A
* WRITTEN AGREEMENT SIGNED BY MULTI-TECH SYSTEMS, INC. IS PROHIBITED.
*
***********************************************************************/

#include "Device.h"

int main(int argc, char const* const argv[]) {
    Device m;
    if (argc < 2) {
        m.printUsage(argv[0]);
    }

    for (int i = 1; i < argc; i++) {
        if (argv[i][0] == '-') {
            std::string parameter = &argv[i][1];
            if (parameter == "-version") {
                m.printVersion(argv[0]);
            } else if (parameter == "-help") {
                m.printUsage(argv[0]);
            } else if (parameter == "-verbose") {
                m.Verbose(true);
            }
        }
    }
    for (int i = 1; i < argc; i++) {
        std::string parameter = argv[i];
        if (parameter == "init") {
            m.init();
        } else if (parameter == "json") {
            m.json();
        } else if (parameter == "show") {
            if (argv[i + 1] && !argv[i + 2]) {
                m.show(argv[i + 1]);
            } else {
                m.logError("show name");
                exitHandler(99);
            }
        } else if (parameter == "show-trigger") {
            if (argv[i + 1] && !argv[i + 2]) {
                m.showTrigger(std::string(argv[i + 1]));
            } else {
                m.logError("show-trigger name");
                exitHandler(99);
            }
        } else if (parameter == "store") {
            if (argv[i + 1] && argv[i + 2] && !argv[i + 3]) {
                m.store(std::string(argv[i + 1]), std::string(argv[i + 2]));
            } else {
                m.logError("store name value");
                exitHandler(99);
            }
        } else if (parameter == "store-trigger") {
            if (argv[i + 1] && argv[i + 2] && !argv[i + 3]) {
                m.storeTrigger(std::string(argv[i + 1]), std::string(argv[i + 2]));
            } else {
                m.logError("store name value");
                exitHandler(99);
            }
        }
    }
    m.printUsage(argv[0]);
}