File: main.cpp

package info (click to toggle)
hashcheck 1.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 136 kB
  • sloc: cpp: 142; makefile: 3
file content (61 lines) | stat: -rw-r--r-- 2,292 bytes parent folder | download
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
/*******************************************************************************
 * Copyright (c) 2017, Kyle Robbertze (AIMS, South Africa)
 *
 * This project is free software: you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License version 3 as 
 * published by the Free Software Foundation.
 *
 * It is distributed in the hope that it will be useful, but WITHOUT 
 * ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this project. If not, see <http://www.gnu.org/licenses/>.
 *
 *    Description:  Main entry point for Hashcheck
 * 
 *        Created:  23/02/2017 10:02:51
 *       Compiler:  g++
 * 
 *         Author:  Kyle Robbertze (kr), kyle@aims.ac.za
 *******************************************************************************/
#include <algorithm>
#include <iostream>
#include <stdlib.h>
#include <string>

#include <QApplication>
#include <QWidget>

#include "main_window.h"

bool cmdOptionExists(char* begin[], char* end[], const std::string& option) {
    return std::find(begin, end, option) != end;
}

int main(int argc, char* argv[]) {
    if (cmdOptionExists(argv, argv+argc, "-v") ||
            cmdOptionExists(argv, argv+argc, "--version")) {
        std::cout << "Hashcheck " << HASHCHECK_VERSION << "\n";
        std::cout << "This project comes with NO WARRANTY, to the extent permitted by the law.\n";
        std::cout << "You may redistribute it under the terms of the GNU General Public License\n";
        std::cout << "version 3; see the file named LICENSE for details.\n\n";
        std::cout << "Written by Kyle Robbertze\n";
        return EXIT_SUCCESS;
    }

    if (argc == 1) {
        QApplication app { argc, argv };
        MainWindow window{};
        window.setWindowTitle("Hashcheck");
        window.show();

        return app.exec();
    }
    std::cout << "useage: hashcheck [-h] [-v]\n\n";
    std::cout << "optional arguments:\n";
    std::cout << "-h, --help\tshow this help message and exit\n";
    std::cout << "-v, --version\toutput the version information and exit\n";
    return EXIT_SUCCESS;
}