Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add additional step in dipdup new to choose addons #1130

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/dipdup/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ def install(
update: bool = False,
with_pdm: bool = False,
with_poetry: bool = False,
addons: list[str] = None,
) -> None:
"""Install DipDup and its dependencies with pipx"""
if ref and path:
Expand Down Expand Up @@ -245,6 +246,9 @@ def install(
echo(f'Installing `{pm}`')
env.run_cmd('pipx', 'install', '--python', python_inter_pipx, *pipx_args, pm)
env._commands[pm] = which(pm)

if addons:
update_replay_yaml(addons)

done(
'Done! DipDup is ready to use.\n'
Expand All @@ -263,6 +267,25 @@ def ask(question: str, default: bool) -> bool:
if answer in ('y', 'yes'):
return True

def ask_for_addons() -> list[str]:
addons = []
available_addons = ['swarm_deploy', 'squid_cloud_deploy'] # Define your addons here
print("Select optional addons (leave blank to skip):")
for addon in available_addons:
response = input(f"Include {addon.replace('_', ' ').title()}? (y/n): ").lower()
if response.startswith('y'):
addons.append(addon)
return addons

def update_replay_yaml(addons: list[str]) -> None:
replay_path = Path('../demo_tezos_factories/configs/replay.yaml')
if replay_path.exists():
with replay_path.open('a') as replay_file:
replay_file.write("\naddons:\n")
for addon in addons:
replay_file.write(f" - {addon}\n")



def uninstall(quiet: bool) -> NoReturn:
"""Uninstall DipDup and its dependencies with pipx"""
Expand Down Expand Up @@ -295,9 +318,11 @@ def cli() -> None:
parser.add_argument('--with-pdm', action='store_true', help='Install PDM')
parser.add_argument('--with-poetry', action='store_true', help='Install Poetry')
args = parser.parse_args()
addons = []

if not args.quiet:
sys.stdin = open('/dev/tty') # noqa: PTH123
addons = ask_for_addons()

if args.uninstall:
uninstall(args.quiet)
Expand All @@ -313,6 +338,7 @@ def cli() -> None:
update=args.update,
with_pdm=args.with_pdm,
with_poetry=args.with_poetry,
addons=addons,
)


Expand Down