Skip to content
Snippets Groups Projects
Select Git revision
  • d5c25742fc80b89ac047037172e1a0120cd97244
  • master default protected
  • cali
  • dev protected
4 results

main.cpp

  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    main.cpp 2.93 KiB
    #include "../utils.h"
    
    #include <iostream>
    
    #include <QCoreApplication>
    #include <QCommandLineParser>
    #include <QDir>
    
    using Qt::endl;
    using namespace std;
    
    int main(int argc, char *argv[])
    {
    
        QCoreApplication a(argc, argv);
        QCoreApplication::setApplicationVersion(getVersionString());
        QCoreApplication::setApplicationName("recorder (cmd-line)");
    
        QTextStream qout(stdout); //2d make global to access from anywhere
        QTextStream qin(stdin);
        qin.skipWhiteSpace(); // Remove white characters that interrupt
        QTextStream qerr(stderr);
    
        // parse arguments
        QCommandLineParser parser;
        parser.setApplicationDescription("a commandline app that is meant to be standalone and communicates with the camera");
        parser.addHelpOption();
        parser.addVersionOption();
        parser.addOptions({
            {{"o", "out-dir"}, "store frames to <out-dir>", "out_dir"},
            {{"l", "list-cams"}, "list available cams"},
            {{"e", "export-cam-config"}, "export camera config" "settings.xml"},
            {{"i", "import-cam-config"}, "import camera config" "settings.xml"},
            {{"c", "calibrate"}, "calibrate cam"},
            {{"r", "record"}, "record"},
            {{"s", "stop"}, "stop recording"},
            // {{"f", "force"}, "Overwrite existing files."},
            // {{"n", "dry-run"}, "Do nothing. For testing purposes."},
            // {{"p", "progress"}, "Show progress during copy."},
            // {{"v", "verbose"}, "verbose"},
        });
    
        parser.process(a);
    
        const QStringList args = parser.positionalArguments();
        // source is args.at(0), destination is args.at(1)
        qDebug() << "args: " << args.join(", ") << "\n";
    
    
        qout << "Please enter your name: ";
        qout.flush(); // clears the keyboard buffer
    
        QString inpu;
    
        // QString inpu = qin.readLine();
        qin >> inpu;
    
        qout << "u typed " << inpu.toLower() << endl;
    
        return 3;
    
        cout << "__LINE__" << __LINE__ << endl; //2d make snippet HERE for dbg
        if( parser.isSet("o") )
        {
            QDir out_dir(parser.value("o"));
            if( !out_dir.exists() )
            {
                qDebug() << "out_dir (" << out_dir.absolutePath() << ") doesn't exist. Should I Create it? [y|yes or other]\n";
                QString yn ="";
                qin >> yn;
    
                QStringList yes{"y", "yes", "1", "ja", "j", "oui", "si"};
                if( yes.contains(yn.toLower())  )
                {
                    // out_dir.mkpath(out_dir.absolutePath());
                    if( !out_dir.mkdir(".") ){
                        cerr << "failed to create out_dir '" << out_dir.absolutePath().toStdString()  << "'" << endl;
                        return 1;
                    }
                }
                else
                {
                    cout << "u pressed no" << endl;
                    return 0;
                }
            }
    
    
    
            qDebug() << "out_dir: " << out_dir << "\n";
        }
        // bool force = parser.isSet(forceOption);
        // QString targetDir = parser.value(targetDirectoryOption);
    
    
    
        // return a.exec();
        return 0;
    }