archivebox_shell.py 859 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/env python3
  2. __package__ = 'archivebox.cli'
  3. __command__ = 'archivebox shell'
  4. import sys
  5. import argparse
  6. from pathlib import Path
  7. from typing import Optional, List, IO
  8. from archivebox.misc.util import docstring
  9. from archivebox.config import DATA_DIR
  10. from ..logging_util import SmartFormatter, reject_stdin
  11. from ..main import shell
  12. @docstring(shell.__doc__)
  13. def main(args: Optional[List[str]]=None, stdin: Optional[IO]=None, pwd: Optional[str]=None) -> None:
  14. parser = argparse.ArgumentParser(
  15. prog=__command__,
  16. description=shell.__doc__,
  17. add_help=True,
  18. formatter_class=SmartFormatter,
  19. )
  20. parser.parse_args(args or ())
  21. reject_stdin(__command__, stdin)
  22. shell(
  23. out_dir=Path(pwd) if pwd else DATA_DIR,
  24. )
  25. if __name__ == '__main__':
  26. main(args=sys.argv[1:], stdin=sys.stdin)