Skip to content

dual init interactive devcontainer setup #145

@jeevanpillay

Description

@jeevanpillay

Summary

Make dual init an interactive setup wizard that detects existing devcontainer.json or guides the user through creating one. The result is both .dual/settings.json and .devcontainer/devcontainer.json fully configured.

Interactive Flow

Step 1: Detect existing devcontainer

Detected .devcontainer/devcontainer.json
Use this as your container config? [Y/n]

If yes → set devcontainer path in settings.json, skip to Step 5.
If no existing devcontainer detected → proceed to Step 2.

Step 2: Select base image

Select base image:
  1. node:20 (Node.js)
  2. python:3.12 (Python)
  3. rust:latest (Rust)
  4. Custom (enter image name)
> 

Step 3: Ports

Which ports does your dev server use? (comma-separated, or empty for none)
> 3000

Step 4: Setup command

Setup command after container creation? (e.g., pnpm install, or empty for none)
> pnpm install

Step 5: Summary & confirm

Configuration:
  Image:    node:20
  Ports:    3000
  Setup:    pnpm install

  .dual/settings.json          (Dual config)
  .devcontainer/devcontainer.json  (container config)

Create these files? [Y/n]

Implementation

  1. New src/init.rs module — interactive prompts using stdin/stdout
  2. cmd_init() rewrite — call init module, write both config files
  3. Non-interactive modedual init --yes or dual init -y accepts all defaults (node:20, no ports, no setup)
  4. Writes:
    • .dual/settings.json with devcontainer path + defaults
    • .devcontainer/devcontainer.json with user selections (only if creating new)
  5. Existing behavior preserved — still registers workspace in global state, installs shell hook

Edge Cases

  • .dual/settings.json already exists → warn and ask to overwrite
  • .devcontainer/devcontainer.json already exists → use it, don't overwrite
  • Not in a git repo → error (same as current dual add)

Tests

  • Non-interactive mode (--yes) creates correct defaults
  • Existing devcontainer detection works
  • Generated devcontainer.json is valid JSON
  • Generated settings.json has correct devcontainer path

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions