cli.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import click
  2. import logging
  3. from rich.logging import RichHandler
  4. from vibroscopio.fingerprint import correlate, signature
  5. @click.group()
  6. @click.option('--verbosity', '-v', default=2, count=True)
  7. def cli(verbosity):
  8. FORMAT = "%(message)s"
  9. logging.basicConfig(
  10. level=verbosity * 10,
  11. format=FORMAT,
  12. datefmt="[%X]",
  13. handlers=[RichHandler()])
  14. @click.command()
  15. @click.argument('file')
  16. def fingerprint(path):
  17. s = signature(path)
  18. print(s)
  19. @click.command()
  20. @click.option('--source', '-s', help='source is expected to be bigger than target', type=click.Path(exists=True))
  21. @click.option('--target', '-t', help='target is supposed to be smaller than source', type=click.Path(exists=True))
  22. @click.option('--length', '-l', default=120, help='seconds of source length')
  23. @click.option('--span', '-s', default=60, help='allowd span allignment in seconds')
  24. def compare(source, target, length, span):
  25. correlate(source, target, length, length * 7)
  26. cli.add_command(fingerprint)
  27. cli.add_command(compare)
  28. def main():
  29. cli()