Skip to content

Commit b1bffce

Browse files
authored
fix: allow skipping confirmations if desired (#93)
1 parent aea02fe commit b1bffce

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

src/ape_plugins/_cli.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,15 @@ def _list(display_all):
8383
@cli.command(short_help="Install an ape plugin")
8484
@click.argument("plugin")
8585
@click.option("-v", "--version", help="Specify version (Default is latest)")
86-
def add(plugin, version):
86+
@click.option(
87+
"-y",
88+
"--yes",
89+
"skip_confirmation",
90+
default=False,
91+
is_flag=True,
92+
help="Don't ask for confirmation to remove plugin",
93+
)
94+
def add(plugin, version, skip_confirmation):
8795
if plugin.startswith("ape"):
8896
raise Abort(f"Namespace 'ape' in '{plugin}' is not required")
8997

@@ -99,8 +107,10 @@ def add(plugin, version):
99107
elif is_plugin_installed(plugin):
100108
raise Abort(f"Plugin '{plugin}' already installed")
101109

102-
elif plugin in SECOND_CLASS_PLUGINS or click.confirm(
103-
f"Install unknown 3rd party plugin '{plugin}'?"
110+
elif (
111+
plugin in SECOND_CLASS_PLUGINS
112+
or skip_confirmation
113+
or click.confirm(f"Install unknown 3rd party plugin '{plugin}'?")
104114
):
105115
notify("INFO", f"Installing {plugin}...")
106116
# NOTE: Be *extremely careful* with this command, as it modifies the user's
@@ -110,14 +120,22 @@ def add(plugin, version):
110120

111121

112122
@cli.command(short_help="Install all plugins in the local config file")
113-
@click.pass_context
114-
def install(ctx):
123+
@click.option(
124+
"-y",
125+
"--yes",
126+
"skip_confirmation",
127+
default=False,
128+
is_flag=True,
129+
help="Don't ask for confirmation to remove plugin",
130+
)
131+
def install(skip_confirmation):
115132
for plugin, version in config.get_config("plugins").items():
116133
if not plugin.startswith("ape-"):
117134
raise Abort(f"Namespace 'ape' required in config item '{plugin}'")
118135

119136
if not is_plugin_installed(plugin.replace("-", "_")) and (
120137
plugin.replace("-", "_") in SECOND_CLASS_PLUGINS
138+
or skip_confirmation
121139
or click.confirm(f"Install unknown 3rd party plugin '{plugin}'?")
122140
):
123141
notify("INFO", f"Installing {plugin}...")

0 commit comments

Comments
 (0)