All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.timm.cucumber.options.RuntimeOptions Maven / Gradle / Ivy

package com.github.timm.cucumber.options;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;


/**
 * Copyright (c) 2008-2014 The Cucumber Organisation
 *
 * Fork of https://github.com/cucumber/cucumber-jvm/blob/master/core/src/main/java/cucumber/runtime/RuntimeOptions.java
 */
public class RuntimeOptions {
    static String usageText;

    private final List glue = new ArrayList();
    private final List filters = new ArrayList();
    private final List pluginNames = new LinkedList();
    private boolean dryRun;
    private boolean strict = false;
    private boolean monochrome = false;

    /**
     * Create a new instance from a string of options, for example:
     *
     * 
"--name 'the fox' --plugin pretty --strict"
* * @param argv the arguments */ public RuntimeOptions(final String argv) { this(Shellwords.parse(argv)); } /** * Create a new instance from a list of options, for example: * *
Arrays.asList("--name", "the fox", "--plugin", "pretty", "--strict");
* * @param argv the arguments */ public RuntimeOptions(List argv) { argv = new ArrayList(argv); // in case the one passed in is unmodifiable. parse(argv); } private void parse(final List args) { final List parsedFilters = new ArrayList(); // final List parsedFeaturePaths = new ArrayList(); final List parsedGlue = new ArrayList(); while (!args.isEmpty()) { final String arg = args.remove(0).trim(); if (arg.equals("--glue") || arg.equals("-g")) { final String gluePath = args.remove(0); parsedGlue.add(gluePath); } else if (arg.equals("--tags") || arg.equals("-t")) { parsedFilters.add(args.remove(0)); } else if (arg.equals("--plugin") || arg.equals("-p")) { addPluginName(args.remove(0)); } else if (arg.equals("--format") || arg.equals("-f")) { System.err.println("WARNING: Cucumber-JVM's --format option is deprecated. Please use --plugin instead."); addPluginName(args.remove(0)); } else if (arg.equals("--no-dry-run") || arg.equals("--dry-run") || arg.equals("-d")) { dryRun = !arg.startsWith("--no-"); } else if (arg.equals("--no-strict") || arg.equals("--strict") || arg.equals("-s")) { strict = !arg.startsWith("--no-"); } else if (arg.equals("--no-monochrome") || arg.equals("--monochrome") || arg.equals("-m")) { monochrome = !arg.startsWith("--no-"); } else { // ignore } } if (!parsedFilters.isEmpty() ) { filters.clear(); filters.addAll(parsedFilters); } if (!parsedGlue.isEmpty()) { glue.clear(); glue.addAll(parsedGlue); } } private void addPluginName(final String plugin) { pluginNames.add(plugin); } public List getGlue() { return glue; } public boolean isStrict() { return strict; } public boolean isDryRun() { return dryRun; } public List getFilters() { return filters; } public boolean isMonochrome() { return monochrome; } public List getPluginNames() { return pluginNames; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy