python import click @click.command() @click.argument('name', autocompletion=my_autocomplete_function) def greet(name): click.echo(f"Hello, {name}!") def my_autocomplete_function(ctx, incomplete): completions = ["world", "click", "python"] return [c for c in completions if c.startswith(incomplete)] if __name__ == '__main__': greet() python from prompt_toolkit import PromptSession def main(): session = PromptSession(history=my_command_history_function) text = session.prompt('>>> ') print(f'You entered: {text}') def my_command_history_function(): return ['command1', 'command2', 'command3'] if __name__ == '__main__': main()


上一篇:
下一篇:
切换中文