archivebox_help.py 835 B

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env python3
  2. __package__ = 'archivebox.cli'
  3. __command__ = 'archivebox help'
  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 ..main import help
  11. from ..logging_util import SmartFormatter, reject_stdin
  12. @docstring(help.__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=help.__doc__,
  17. add_help=True,
  18. formatter_class=SmartFormatter,
  19. )
  20. parser.parse_args(args or ())
  21. reject_stdin(__command__, stdin)
  22. help(out_dir=Path(pwd) if pwd else DATA_DIR)
  23. if __name__ == '__main__':
  24. main(args=sys.argv[1:], stdin=sys.stdin)