Esempio n. 1
0
bool mvle_parse_arg(int argc, char **argv, int *vpz, bool *show,
        vle::utils::Package& pack)
{
    int i = 1;

    while (i < argc) {
        if ((std::strcmp(argv[i], "-P") == 0 or
             std::strcmp(argv[i], "--package") == 0) and i + 1 <= argc) {
            pack.select(argv[++i]);
        } else if (std::strcmp(argv[i], "-h") == 0 or
                   std::strcmp(argv[i], "--help") == 0) {
            mvle_show_help();
            return false;
        } else if (std::strcmp(argv[i], "-v") == 0 or
                   std::strcmp(argv[i], "--version") == 0) {
            mvle_show_version();
            return false;
        } else if (std::strcmp(argv[i], "-s") == 0 or
                   std::strcmp(argv[i], "--show") == 0) {
            *show = true;
        } else {
            *vpz = i;
        }
        ++i;
    }

    return *vpz < argc and not pack.name().empty();
}
Esempio n. 2
0
static bool init_package(vle::utils::Package& pkg, const CmdArgs &args)
{

    if (not pkg.existsBinary()) {
        if (not pkg.existsSource()) {
            if (std::find(args.begin(), args.end(), "create") == args.end()) {
                std::cerr << vle::fmt(
                    _("Package `%1%' does not exist. Use the create command"
                      " before other command.\n")) % pkg.name();

                return false;
            }
        }
    }
    return true;
}
Esempio n. 3
0
static std::string search_vpz(const std::string &param,
        vle::utils::Package& pkg)
{
    assert(not pkg.name().empty());
    if (vle::utils::Path::existFile(param))
        return param;

    std::string np = pkg.getExpFile(param, vle::utils::PKG_BINARY);

    if (vle::utils::Path::existFile(np))
        return np;

    std::cerr << vle::fmt(_("Filename '%1%' does not exist")) % param;

    return std::string();
}
Esempio n. 4
0
static void show_package_content(vle::utils::Package& pkg)
{

    std::cout << vle::fmt(_("Package content from: `%1%'\n")) %
            pkg.getDir(vle::utils::PKG_BINARY);

    vle::utils::PathList tmp;

    vle::utils::Package pack(pkg.name());
    try {
        tmp = pack.getExperiments();
    } catch (const std::exception &e) {
        std::cerr << vle::fmt(_("Show package content error: %1%\n")) % e.what();
        return;
    }
    std::cout << "-- experiments : " << std::endl;
    std::sort(tmp.begin(), tmp.end());
    std::copy(tmp.begin(), tmp.end(),
              std::ostream_iterator < std::string >(std::cout, "\n"));

    tmp = pkg.getPluginsSimulator();

    std::cout << "-- simulator plugins : " << std::endl;
    std::sort(tmp.begin(), tmp.end());
    std::copy(tmp.begin(), tmp.end(),
              std::ostream_iterator < std::string >(std::cout, "\n"));

    tmp = pkg.getPluginsOutput();

    std::cout << "-- output plugins : " << std::endl;
    std::sort(tmp.begin(), tmp.end());
    std::copy(tmp.begin(), tmp.end(),
              std::ostream_iterator < std::string >(std::cout, "\n"));

    tmp = pkg.getPluginsGvleGlobal();

    std::cout << "-- gvle global plugins : " << std::endl;
    std::sort(tmp.begin(), tmp.end());
    std::copy(tmp.begin(), tmp.end(),
              std::ostream_iterator < std::string >(std::cout, "\n"));

    tmp = pkg.getPluginsGvleModeling();

    std::cout << "-- gvle modeling plugins : " << std::endl;
    std::sort(tmp.begin(), tmp.end());
    std::copy(tmp.begin(), tmp.end(),
              std::ostream_iterator < std::string >(std::cout, "\n"));

    tmp = pkg.getPluginsGvleOutput();

    std::cout << "-- gvle output plugins : " << std::endl;
    std::sort(tmp.begin(), tmp.end());
    std::copy(tmp.begin(), tmp.end(),
              std::ostream_iterator < std::string >(std::cout, "\n"));
}