mirror of
https://github.com/yavook/kiwi-scp.git
synced 2024-11-22 04:43:00 +00:00
neater prompts
This commit is contained in:
parent
679a47e4fa
commit
81b597cb58
3 changed files with 29 additions and 3 deletions
|
@ -14,7 +14,12 @@ class DownCommand(FlexCommand):
|
|||
)
|
||||
|
||||
def _run_instance(self, runner, config, args):
|
||||
if are_you_sure("This will bring down the entire instance."):
|
||||
if are_you_sure([
|
||||
"This will bring down the entire instance.",
|
||||
"",
|
||||
"This may not be what you intended, because:",
|
||||
" - Bringing down the instance stops ALL services in here",
|
||||
]):
|
||||
return super()._run_instance(runner, config, args)
|
||||
|
||||
return False
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
# local
|
||||
from ._subcommand import FlexCommand
|
||||
from .utils.misc import are_you_sure
|
||||
|
||||
|
||||
class UpdateCommand(FlexCommand):
|
||||
|
@ -11,6 +12,18 @@ class UpdateCommand(FlexCommand):
|
|||
description="Update the whole instance, a project or service(s) inside a project"
|
||||
)
|
||||
|
||||
def _run_instance(self, runner, config, args):
|
||||
if are_you_sure([
|
||||
"This will update the entire instance at once.",
|
||||
"",
|
||||
"This is probably not what you intended, because:",
|
||||
" - Updates may take a long time",
|
||||
" - Updates may break beloved functionality",
|
||||
]):
|
||||
return super()._run_instance(runner, config, args)
|
||||
|
||||
return False
|
||||
|
||||
def _run_services(self, runner, config, args, services):
|
||||
result = runner.run('build')
|
||||
result &= runner.run('pull')
|
||||
|
|
|
@ -59,6 +59,14 @@ def _surround(string, bang):
|
|||
return f"{sidelane}\n{midlane}\n{sidelane}"
|
||||
|
||||
|
||||
def _emphasize(lines):
|
||||
if isinstance(lines, list):
|
||||
return '\n'.join([_emphasize(line) for line in lines])
|
||||
elif lines:
|
||||
return f">>> {lines} <<<"
|
||||
else:
|
||||
return lines
|
||||
|
||||
def are_you_sure(prompt, default="no"):
|
||||
if default.lower() == 'yes':
|
||||
suffix = "[YES|no]"
|
||||
|
@ -66,9 +74,9 @@ def are_you_sure(prompt, default="no"):
|
|||
suffix = "[yes|NO]"
|
||||
|
||||
answer = input(
|
||||
f"{_surround('CAREFULING IN PROGRESS', '!')}\n"
|
||||
f"{_surround('MUST HAVE CAREFULING IN PROGRESS', '!')}\n"
|
||||
f"\n"
|
||||
f">>> {prompt} <<<\n"
|
||||
f"{_emphasize(prompt)}\n"
|
||||
f"\n"
|
||||
f"Are you sure you want to proceed? {suffix} "
|
||||
).strip().lower()
|
||||
|
|
Loading…
Reference in a new issue