Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Installation is done via pip:
pip install click-repl
In your click app:
import click
from click_repl import register_repl
@click.group()
def cli():
pass
@cli.command()
def hello():
click.echo("Hello world!")
register_repl(cli)
cli()
In the shell:
$ my_app repl
> hello
Hello world!
> ^C
$ echo hello | my_app repl
Hello world!
Features not shown:
ctx.obj
persists between
subcommands. If you're keeping caches on that object (like I do), using the
app's repl instead of the shell is a huge performance win.!
- prefix executes shell commands.You can use the internal :help
command to explain usage.
For more flexibility over how your REPL works you can use the repl
function
directly instead of register_repl
. For example, in your app:
import click
from click_repl import repl
from prompt_toolkit.history import FileHistory
@click.group()
def cli():
pass
@cli.command()
def myrepl():
prompt_kwargs = {
'history': FileHistory('/etc/myrepl/myrepl-history'),
}
repl(click.get_current_context(), prompt_kwargs=prompt_kwargs)
cli()
And then your custom myrepl
command will be available on your CLI, which
will start a REPL which has its history stored in
/etc/myrepl/myrepl-history
and persist between sessions.
Any arguments that can be passed to the python-prompt-toolkit
Prompt class
can be passed in the prompt_kwargs
argument and will be used when
instantiating your Prompt
.
FAQs
REPL plugin for Click
We found that click-repl demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.