diff --git a/README.md b/README.md index 3ea1e20..081f42f 100644 --- a/README.md +++ b/README.md @@ -59,10 +59,29 @@ Options: --incremental TEXT File where incremental mutation state is stored + --config TEXT File to parse vertigo options from --help Show this message and exit. ``` +### Using Configuration File + +At this time a limited set of options have been implemented. + +A user can create a config file in the project root (see sample below) to limit the number of command line parameters used. +```bash +vertigo run --config vertigo_config.yml +``` + +Sample config file: +``` +//vertigo_config.yml +hardhat_parallel: 8 +output: output.txt +``` + +Note that unused fields in the config file should be `false`. + ### Known Issues **Ganache** is generally used only for a single run of the entire test suite. diff --git a/eth_vertigo/cli/main.py b/eth_vertigo/cli/main.py index 43fdf45..5742b57 100644 --- a/eth_vertigo/cli/main.py +++ b/eth_vertigo/cli/main.py @@ -1,4 +1,5 @@ import click +import yaml from os import getcwd from pathlib import Path from eth_vertigo.core import MutationResult @@ -32,8 +33,9 @@ def cli(): @click.option('--truffle-location', help="Location of truffle cli", nargs=1, type=str, default="truffle") @click.option('--sample-ratio', help="If this option is set. Vertigo will apply the sample filter with the given ratio", nargs=1, type=float) @click.option('--exclude', help="Vertigo won't mutate files in these directories", multiple=True) -@click.option('--incremental', help="File where incremental mutation state is stored", - type=str) +@click.option('--incremental', help="File where incremental mutation state is stored",type=str) +@click.option('--config', help="Pulls CLI parameters from .yml file. (requires file name)", nargs=1, type=str) + def run( output, network, @@ -45,7 +47,8 @@ def run( truffle_location, sample_ratio, exclude, - incremental + incremental, + config ): """ Run command """ click.echo("[*] Starting mutation testing") @@ -55,6 +58,7 @@ def run( working_directory = getcwd() project_type = _directory_type(working_directory) filters = [] + if exclude: filters.append(ExcludeFilter(exclude)) @@ -74,6 +78,13 @@ def run( store = IncrementalMutationStore.from_file(incremental_store_file) test_suggesters.append(IncrementalSuggester(store)) + if config: + with open(config, 'r') as file: + config_params = yaml.safe_load(file) + + output = config_params['output'] + hardhat_parallel = config_params['hardhat_parallel'] + click.echo("[*] Starting analysis on project") project_path = Path(working_directory)