mirror of
https://github.com/google/bumble.git
synced 2026-06-01 07:37:02 +00:00
Merge pull request #41 from google/gbg/cli-scripts
use arg-less main() functions in all scripts
This commit is contained in:
+2
-2
@@ -90,7 +90,7 @@ class SnoopPacketReader:
|
|||||||
@click.command()
|
@click.command()
|
||||||
@click.option('--format', type=click.Choice(['h4', 'snoop']), default='h4', help='Format of the input file')
|
@click.option('--format', type=click.Choice(['h4', 'snoop']), default='h4', help='Format of the input file')
|
||||||
@click.argument('filename')
|
@click.argument('filename')
|
||||||
def show(format, filename):
|
def main(format, filename):
|
||||||
input = open(filename, 'rb')
|
input = open(filename, 'rb')
|
||||||
if format == 'h4':
|
if format == 'h4':
|
||||||
packet_reader = PacketReader(input)
|
packet_reader = PacketReader(input)
|
||||||
@@ -117,4 +117,4 @@ def show(format, filename):
|
|||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
show()
|
main()
|
||||||
|
|||||||
+4
-6
@@ -29,6 +29,7 @@
|
|||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
|
import click
|
||||||
import usb1
|
import usb1
|
||||||
from colors import color
|
from colors import color
|
||||||
|
|
||||||
@@ -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):
|
def main(verbose):
|
||||||
logging.basicConfig(level = os.environ.get('BUMBLE_LOGLEVEL', 'WARNING').upper())
|
logging.basicConfig(level = os.environ.get('BUMBLE_LOGLEVEL', 'WARNING').upper())
|
||||||
|
|
||||||
@@ -233,9 +236,4 @@ def main(verbose):
|
|||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if len(sys.argv) == 2 and sys.argv[1] == '--verbose':
|
main()
|
||||||
verbose = True
|
|
||||||
else:
|
|
||||||
verbose = False
|
|
||||||
|
|
||||||
main(verbose)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user