From cf9fcd79ebe3e6a13e8577d17771ab53313f982a Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 21 Jul 2018 17:00:18 +0200 Subject: [PATCH] write_coverage: add support for --append (#49) --- covimerage/cli.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/covimerage/cli.py b/covimerage/cli.py index 6fa6893c..e21aee2f 100644 --- a/covimerage/cli.py +++ b/covimerage/cli.py @@ -42,13 +42,20 @@ def main(ctx, verbose, quiet, loglevel, rcfile): @click.option('--source', type=click.types.Path(exists=True), help=( 'Source files/dirs to include. This is necessary to include completely ' 'uncovered files.'), show_default=True, multiple=True) -def write_coverage(profile_file, data_file, source): +@click.option('--append', is_flag=True, default=False, show_default=True, + help='Read existing DATA_FILE for appending.') +def write_coverage(profile_file, data_file, source, append): """ Parse PROFILE_FILE (output from Vim's :profile) and write it into DATA_FILE (Coverage.py compatible). """ - m = MergedProfiles(source=source) + if append: + m = MergedProfiles(source=source, append_to=data_file) + else: + m = MergedProfiles(source=source) + m.add_profile_files(*profile_file) + if not m.write_coveragepy_data(data_file=data_file): raise CustomClickException('No data to report.')