~larryprice/+junk/terminal-helper

« back to all changes in this revision

Viewing changes to src/app/main.cpp

  • Committer: Larry Price
  • Date: 2016-06-16 14:33:43 UTC
  • Revision ID: larry.price@canonical.com-20160616143343-lrvaopp05k7ektj1
Running a single command and then exiting

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
    setenv("TERM", "xterm", 0);
78
78
 
79
79
    QStringList args = a.arguments();
80
 
    if (args.contains("-h") || args.contains("--help")) {
81
 
        qDebug() << "usage: " + args.at(0) + " [--workdir <dir>] [-h|--help]";
82
 
        qDebug() << "    -h|--help     Print this help.";
83
 
        qDebug() << " --workdir <dir> Change working directory to 'dir'";
84
 
        return 0;
85
 
    }
86
 
 
87
 
    //Dynamic folder home
88
 
    view.engine()->rootContext()->setContextProperty("workdir", getNamedArgument(args, "--workdir", "$HOME"));
 
80
    if (args.length() < 2) {
 
81
        qDebug() << "usage: " + args.at(0) + " command [-- args]";
 
82
        return 1;
 
83
    }
 
84
 
 
85
    view.engine()->rootContext()->setContextProperty("command", args[1]);
 
86
 
 
87
    auto argsIdx = args.indexOf("--");
 
88
    QStringList arguments;
 
89
    if (argsIdx != -1)
 
90
    {
 
91
      arguments = args.mid(argsIdx+1);
 
92
    }
 
93
    view.engine()->rootContext()->setContextProperty("args", arguments);
 
94
 
 
95
    // Dynamic folder home
 
96
    view.engine()->rootContext()->setContextProperty("workdir", "$HOME");
89
97
 
90
98
    QStringList keyboardLayouts;
91
99
    // load the qml file