[Notes] [Git][BuildStream/buildstream][issue-638-validate-all-files] Added --all functionality to `bst show`



Title: GitLab

Phillip Smyth pushed to branch issue-638-validate-all-files at BuildStream / buildstream

Commits:

1 changed file:

Changes:

  • buildstream/_frontend/cli.py
    ... ... @@ -166,6 +166,24 @@ original_main = click.BaseCommand.main
    166 166
     click.BaseCommand.main = override_main
    
    167 167
     
    
    168 168
     
    
    169
    +def get_files(directory, *excludes):
    
    170
    +    import re
    
    171
    +    output = tuple()
    
    172
    +    for root, _, files in os.walk(directory):
    
    173
    +        for file in files:
    
    174
    +            if excludes:
    
    175
    +                for regex in excludes:
    
    176
    +                    if not re.match(regex, file):
    
    177
    +                        relDir = os.path.relpath(root, directory)
    
    178
    +                        relFile = os.path.join(relDir, file).strip("./")
    
    179
    +                        output = output + (relFile,)
    
    180
    +            else:
    
    181
    +                relDir = os.path.relpath(root, directory)
    
    182
    +                relFile = os.path.join(relDir, file).strip("./")
    
    183
    +                output = output + (relFile,)
    
    184
    +    return output
    
    185
    +
    
    186
    +
    
    169 187
     ##################################################################
    
    170 188
     #                          Main Options                          #
    
    171 189
     ##################################################################
    
    ... ... @@ -487,6 +505,8 @@ def push(app, elements, deps, remote):
    487 505
     @click.option('--deps', '-d', default='all',
    
    488 506
                   type=click.Choice(['none', 'plan', 'run', 'build', 'all']),
    
    489 507
                   help='The dependencies to show (default: all)')
    
    508
    +@click.option('--all', 'all_', default=False, is_flag=True,
    
    509
    +              help="Validate all files in project")
    
    490 510
     @click.option('--order', default="stage",
    
    491 511
                   type=click.Choice(['stage', 'alpha']),
    
    492 512
                   help='Staging or alphabetic ordering of dependencies')
    
    ... ... @@ -496,7 +516,7 @@ def push(app, elements, deps, remote):
    496 516
     @click.argument('elements', nargs=-1,
    
    497 517
                     type=click.Path(readable=False))
    
    498 518
     @click.pass_obj
    
    499
    -def show(app, elements, deps, except_, order, format_):
    
    519
    +def show(app, elements, deps, except_, order, format_, all_):
    
    500 520
         """Show elements in the pipeline
    
    501 521
     
    
    502 522
         By default this will show all of the dependencies of the
    
    ... ... @@ -543,6 +563,10 @@ def show(app, elements, deps, except_, order, format_):
    543 563
             bst show target.bst --format \\
    
    544 564
                 $'---------- %{name} ----------\\n%{vars}'
    
    545 565
         """
    
    566
    +
    
    567
    +    if all_:
    
    568
    +        elements = get_files("elements", r"^\..*", r".*~$")
    
    569
    +
    
    546 570
         with app.initialized():
    
    547 571
             dependencies = app.stream.load_selection(elements,
    
    548 572
                                                      selection=deps,
    



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]