MCPcopy Index your code
hub / github.com/RustPython/RustPython / cli

Function cli

Lib/pydoc.py:2800–2884  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

2798
2799
2800def cli():
2801 """Command-line interface (looks at sys.argv to decide what to do)."""
2802 import getopt
2803 class BadUsage(Exception): pass
2804
2805 _adjust_cli_sys_path()
2806
2807 try:
2808 opts, args = getopt.getopt(sys.argv[1:], 'bk:n:p:w')
2809 writing = False
2810 start_server = False
2811 open_browser = False
2812 port = 0
2813 hostname = 'localhost'
2814 for opt, val in opts:
2815 if opt == '-b':
2816 start_server = True
2817 open_browser = True
2818 if opt == '-k':
2819 apropos(val)
2820 return
2821 if opt == '-p':
2822 start_server = True
2823 port = val
2824 if opt == '-w':
2825 writing = True
2826 if opt == '-n':
2827 start_server = True
2828 hostname = val
2829
2830 if start_server:
2831 browse(port, hostname=hostname, open_browser=open_browser)
2832 return
2833
2834 if not args: raise BadUsage
2835 for arg in args:
2836 if ispath(arg) and not os.path.exists(arg):
2837 print('file %r does not exist' % arg)
2838 sys.exit(1)
2839 try:
2840 if ispath(arg) and os.path.isfile(arg):
2841 arg = importfile(arg)
2842 if writing:
2843 if ispath(arg) and os.path.isdir(arg):
2844 writedocs(arg)
2845 else:
2846 writedoc(arg)
2847 else:
2848 help.help(arg, is_cli=True)
2849 except (ImportError, ErrorDuringImport) as value:
2850 print(value)
2851 sys.exit(1)
2852
2853 except (getopt.error, BadUsage):
2854 cmd = os.path.splitext(os.path.basename(sys.argv[0]))[0]
2855 print("""pydoc - the Python documentation tool
2856
2857{cmd} <name> ...

Callers 3

pydoc.pyFile · 0.85
_do_testMethod · 0.85
run_cliMethod · 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
existsMethod · 0.45
exitMethod · 0.45

Tested by 2

_do_testMethod · 0.68
run_cliMethod · 0.68