Skip to content

Commit

Permalink
Merge pull request #41 from google/gbg/cli-scripts
Browse files Browse the repository at this point in the history
use arg-less main() functions in all scripts
  • Loading branch information
barbibulle authored Oct 7, 2022
2 parents 2fc7a0b + d1e119f commit fbb46dd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions apps/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def next_packet(self):
@click.command()
@click.option('--format', type=click.Choice(['h4', 'snoop']), default='h4', help='Format of the input file')
@click.argument('filename')
def show(format, filename):
def main(format, filename):
input = open(filename, 'rb')
if format == 'h4':
packet_reader = PacketReader(input)
Expand All @@ -117,4 +117,4 @@ def read_next_packet():

# -----------------------------------------------------------------------------
if __name__ == '__main__':
show()
main()
10 changes: 4 additions & 6 deletions apps/usb_probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import os
import logging
import sys
import click
import usb1
from colors import color

Expand Down Expand Up @@ -149,6 +150,8 @@ def is_bluetooth_hci(device):


# -----------------------------------------------------------------------------
@click.command()
@click.option('--verbose', is_flag=True, default=False, help='Print more details')
def main(verbose):
logging.basicConfig(level = os.environ.get('BUMBLE_LOGLEVEL', 'WARNING').upper())

Expand Down Expand Up @@ -233,9 +236,4 @@ def main(verbose):

# -----------------------------------------------------------------------------
if __name__ == '__main__':
if len(sys.argv) == 2 and sys.argv[1] == '--verbose':
verbose = True
else:
verbose = False

main(verbose)
main()

0 comments on commit fbb46dd

Please sign in to comment.