MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / cli

Function cli

tools/python-3.11.9-amd64/Lib/pydoc.py:2848–2932  ·  view source on GitHub ↗

Command-line interface (looks at sys.argv to decide what to do).

()

Source from the content-addressed store, hash-verified

2846
2847
2848def cli():
2849 """Command-line interface (looks at sys.argv to decide what to do)."""
2850 import getopt
2851 class BadUsage(Exception): pass
2852
2853 _adjust_cli_sys_path()
2854
2855 try:
2856 opts, args = getopt.getopt(sys.argv[1:], 'bk:n:p:w')
2857 writing = False
2858 start_server = False
2859 open_browser = False
2860 port = 0
2861 hostname = 'localhost'
2862 for opt, val in opts:
2863 if opt == '-b':
2864 start_server = True
2865 open_browser = True
2866 if opt == '-k':
2867 apropos(val)
2868 return
2869 if opt == '-p':
2870 start_server = True
2871 port = val
2872 if opt == '-w':
2873 writing = True
2874 if opt == '-n':
2875 start_server = True
2876 hostname = val
2877
2878 if start_server:
2879 browse(port, hostname=hostname, open_browser=open_browser)
2880 return
2881
2882 if not args: raise BadUsage
2883 for arg in args:
2884 if ispath(arg) and not os.path.exists(arg):
2885 print('file %r does not exist' % arg)
2886 sys.exit(1)
2887 try:
2888 if ispath(arg) and os.path.isfile(arg):
2889 arg = importfile(arg)
2890 if writing:
2891 if ispath(arg) and os.path.isdir(arg):
2892 writedocs(arg)
2893 else:
2894 writedoc(arg)
2895 else:
2896 help.help(arg, is_cli=True)
2897 except (ImportError, ErrorDuringImport) as value:
2898 print(value)
2899 sys.exit(1)
2900
2901 except (getopt.error, BadUsage):
2902 cmd = os.path.splitext(os.path.basename(sys.argv[0]))[0]
2903 print("""pydoc - the Python documentation tool
2904
2905{cmd} <name> ...

Callers 1

pydoc.pyFile · 0.85

Calls 15

_adjust_cli_sys_pathFunction · 0.85
aproposFunction · 0.85
browseFunction · 0.85
ispathFunction · 0.85
importfileFunction · 0.85
writedocsFunction · 0.85
writedocFunction · 0.85
splitextMethod · 0.80
basenameMethod · 0.80
printFunction · 0.50
getoptMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected