|
7 | 7 | / _` |/ _ \ \ / /______/ __/ _ \ / _` |/ _ \ |
8 | 8 | | (_| | __/\ V / | (_| (_) | (_| | __/ |
9 | 9 | \__,_|\___| \_/ \___\___/ \__,_|\___| |
10 | | - project · editor · container — simplified |
11 | | -
|
12 | | -usage: devcode [-h] [-v] {open,new,edit,init,list,ps,completion} ... |
13 | | -
|
14 | | -positional arguments: |
15 | | - {open,new,edit,init,list,ps,completion} |
16 | | -
|
17 | | -options: |
18 | | - -h, --help show this help message and exit |
19 | | - -v, --verbose |
20 | | -
|
| 10 | + project · editor · container — simplified |
21 | 11 | ``` |
22 | 12 |
|
23 | | - |
24 | 13 | [](https://codecov.io/gh/dacrystal/dev-code) |
25 | 14 | [](https://pypi.org/project/dev-code/) |
26 | 15 | [](https://pypi.org/project/dev-code/) |
27 | 16 | [](LICENSE) |
28 | 17 |
|
| 18 | +**One command. Any project. The right devcontainer.** |
29 | 19 |
|
30 | | -*One command. Any project. The right devcontainer.* |
| 20 | +--- |
| 21 | + |
| 22 | +## Why devcode? |
| 23 | + |
| 24 | +If you’ve ever: |
31 | 25 |
|
32 | | -Devcode is a CLI that opens any project in VS Code inside a devcontainer — instantly, using reusable templates you define once. No more hunting config files. No more copy-pasting devcontainer configurations. |
| 26 | +* Copied `.devcontainer/` folders between projects |
| 27 | +* Avoided committing devcontainer configs to repos you don’t control |
| 28 | +* Reconfigured VS Code containers again and again |
33 | 29 |
|
34 | | -Use any template on any project — even repos you don't control or where you'd rather keep the devcontainer out of the repository. |
| 30 | +**devcode fixes this.** |
| 31 | + |
| 32 | +Define your devcontainer once. Reuse it everywhere. Keep your repos clean. |
| 33 | + |
| 34 | +--- |
| 35 | + |
| 36 | +## What it does |
| 37 | + |
| 38 | +`devcode` is a CLI that opens any project in VS Code inside a devcontainer—instantly—using reusable templates. |
35 | 39 |
|
36 | 40 | ```bash |
37 | 41 | # Before devcode |
38 | | -code ~/projects/myhellopy |
39 | | -# → use Dev Containers extension to configure .devcontainer/ |
40 | | -# (or copy-paste devcontainer configurations from another project) |
41 | | -# → "Reopen in Container" → wait for build |
42 | | -# → remember: don't commit .devcontainer to this repo |
| 42 | +code ~/projects/my-app |
| 43 | +# → configure .devcontainer manually (or copy-paste from another project) |
| 44 | +# → reopen in container |
| 45 | +# → remember to not commit .devcontainer to this repo |
| 46 | +# → repeat for every project |
43 | 47 |
|
44 | 48 | # After devcode |
45 | | -devcode open py-dev ~/projects/myhellopy |
| 49 | +devcode open py-dev ~/projects/my-app |
46 | 50 | ``` |
47 | 51 |
|
| 52 | +VS Code opens. The container builds. You're ready to go. |
| 53 | + |
48 | 54 | --- |
49 | 55 |
|
50 | 56 | ## Install |
51 | 57 |
|
| 58 | +Install the `dev-code` package, which provides the `devcode` CLI. |
| 59 | + |
| 60 | +### Option 1 — Install globally (recommended) |
| 61 | + |
52 | 62 | ```bash |
53 | 63 | pip install dev-code |
54 | 64 | ``` |
55 | 65 |
|
56 | | -Or run without installing via **uvx**: |
| 66 | +### Option 2 — Run without installing |
57 | 67 |
|
58 | 68 | ```bash |
59 | 69 | uvx --from dev-code devcode |
60 | 70 | ``` |
61 | 71 |
|
62 | | -**Tip:** Add an alias for the fastest workflow: |
| 72 | +### Optional — Add alias |
63 | 73 |
|
64 | 74 | ```bash |
65 | 75 | alias devcode="uvx --from dev-code devcode" |
66 | 76 | ``` |
67 | 77 |
|
68 | | -> Requires: VS Code with the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) + Docker |
| 78 | +### Requirements |
69 | 79 |
|
70 | | -> **Optional:** Install the [`devcontainer` CLI](https://github.com/devcontainers/cli) for automatic resolution of all `devcontainer.json` variables (e.g. `${localEnv:VAR}`). Without it, devcode uses a Python-based parser that handles `${localEnv:VAR}` only. Install `jq` to improve parsing of `devcontainer.json` files that use comments or non-standard syntax (`jq` does not add variable resolution). |
| 80 | +* VS Code with Dev Containers extension |
| 81 | +* Docker |
71 | 82 |
|
72 | 83 | --- |
73 | 84 |
|
74 | | -## Shell Completion |
75 | | - |
76 | | -Add tab-completion for `devcode` subcommands, template names, and flags. |
| 85 | +## Quick start |
77 | 86 |
|
78 | | -### Bash |
| 87 | +```bash |
| 88 | +# 1. Seed your first template (one-time) |
| 89 | +devcode init |
79 | 90 |
|
80 | | -Add to `~/.bashrc`: |
| 91 | +# 2. Open any project in a container |
| 92 | +devcode open dev-code ~/projects/my-app |
81 | 93 |
|
82 | | -```bash |
83 | | -eval "$(devcode completion bash)" |
| 94 | +# 3. Later: reopen any project instantly |
| 95 | +devcode ps -a -i |
84 | 96 | ``` |
85 | 97 |
|
86 | | -> Requires bash 4.0+. macOS ships bash 3.2 — install bash 5 via Homebrew first. |
| 98 | +Select a project from the list to reopen it in VS Code. |
87 | 99 |
|
88 | | -### Zsh |
| 100 | +--- |
89 | 101 |
|
90 | | -Add to `~/.zshrc` **after** `compinit`: |
| 102 | +## Core concepts |
91 | 103 |
|
92 | | -```zsh |
93 | | -eval "$(devcode completion zsh)" |
| 104 | +### Templates |
| 105 | + |
| 106 | +Reusable devcontainer definitions stored locally—not in your repos. |
| 107 | + |
| 108 | +Default location: |
| 109 | + |
| 110 | +``` |
| 111 | +~/.local/share/dev-code/templates/ |
94 | 112 | ``` |
95 | 113 |
|
96 | | -Completes subcommand names, template names (for `open`, `new`, `edit`), flags, and shell names. |
| 114 | +Override with: |
97 | 115 |
|
98 | | -> **Note:** Shell completion requires `devcode` to be on your `PATH` as a real executable (e.g. `pip install dev-code`). It will not work if you are using the `alias devcode="uvx --from dev-code devcode"` shortcut, because shell completion scripts call `devcode` as a subprocess and aliases are not visible to subprocesses. |
| 116 | +``` |
| 117 | +$DEVCODE_TEMPLATE_DIR |
| 118 | +``` |
99 | 119 |
|
100 | 120 | --- |
101 | 121 |
|
102 | | -## Quick-start |
| 122 | +## Features |
103 | 123 |
|
104 | | -```bash |
105 | | -# 1. Seed your first template |
106 | | -devcode init |
| 124 | +### Core workflow |
107 | 125 |
|
108 | | -# 2. Open any project in a devcontainer |
109 | | -devcode open dev-code ~/projects/my-app |
| 126 | +* **One-command open** — launch any project instantly |
| 127 | +* **Reusable templates** — define once, use everywhere |
| 128 | +* **Works with any repo** — no config changes required |
110 | 129 |
|
111 | | -# That's it. VS Code opens, container spins up. |
112 | | -``` |
| 130 | +### Project switching (power feature) |
113 | 131 |
|
114 | | ---- |
| 132 | +* **Reopen any project instantly** — use `devcode ps -a -i` to list all containers (running and stopped) and interactively reopen one |
| 133 | +* **Container dashboard** — inspect running environments with `devcode ps` |
115 | 134 |
|
116 | | -## Features |
| 135 | +### Customization |
| 136 | + |
| 137 | +* **Custom templates** |
| 138 | +* **File sync on launch** — inject configs, credentials, and secrets safely |
| 139 | + |
| 140 | +### Environment support |
117 | 141 |
|
118 | | -- **One-command open** — `devcode open <template> <path>` launches VS Code in a devcontainer instantly |
119 | | -- **Reusable templates** — define your devcontainer once, reuse it across every project |
120 | | -- **Built-in template** — ships with the `dev-code` template out of the box |
121 | | -- **Custom templates** — create and manage your own with `devcode new` |
122 | | -- **File sync on launch** — copy credentials, configs, and secrets into the container via a `dev-code` customization block in `devcontainer.json` |
123 | | -- **WSL support** — works natively on Windows Subsystem for Linux |
124 | | -- **Container dashboard** — see all running devcontainers with `devcode ps` |
125 | | -- **Works with existing config** — no new format, just standard `devcontainer.json` |
| 142 | +* **WSL support** |
| 143 | +* **Standard devcontainer format** |
126 | 144 |
|
127 | 145 | --- |
128 | 146 |
|
129 | 147 | ## Commands |
130 | 148 |
|
131 | | -| Command | Description | |
132 | | -|---|---| |
133 | | -| `devcode init` | Seed the built-in `dev-code` template into your template directory | |
134 | | -| `devcode open <template> <path>` | Open a project in VS Code using a devcontainer template | |
135 | | -| `devcode new <name> [base]` | Create a new template (optionally based on an existing one) | |
136 | | -| `devcode edit [template]` | Open a template for editing in VS Code | |
137 | | -| `devcode list [--long]` | List available templates | |
138 | | -| `devcode ps` | Show running devcontainers | |
139 | | -| `devcode completion <shell>` | Print shell completion script (`bash` or `zsh`) | |
140 | | - |
141 | | -### Options |
142 | | - |
143 | | -| Flag | Command | Description | |
144 | | -|---|---|---| |
145 | | -| `--dry-run` | `open` | Print the devcontainer URI and copy plan without executing | |
146 | | -| `--container-folder` | `open` | Override the in-container workspace path | |
147 | | -| `--timeout` | `open` | Seconds to wait for container to start (default: 300) | |
148 | | -| `--edit` | `new` | Open the new template for editing immediately after creation | |
149 | | -| `--long` | `list` | Show full paths alongside template names | |
150 | | -| `-v, --verbose` | all | Enable debug logging | |
| 149 | +| Command | Description | |
| 150 | +| -------------------------------- | -------------------------------------------------------------- | |
| 151 | +| `devcode open <template> <path>` | Open a project using a template | |
| 152 | +| `devcode init` | Seed the default template | |
| 153 | +| `devcode new <name> [base]` | Create a new template | |
| 154 | +| `devcode edit [template]` | Edit a template | |
| 155 | +| `devcode list [--long]` | List templates | |
| 156 | +| `devcode ps [-a] [-i]` | List containers (`-a` includes stopped, `-i` interactive mode) | |
| 157 | +| `devcode completion <shell>` | Generate shell completion | |
151 | 158 |
|
152 | | ---- |
| 159 | +### Examples |
153 | 160 |
|
154 | | -## Templates |
| 161 | +```bash |
| 162 | +# Show running containers |
| 163 | +devcode ps |
155 | 164 |
|
156 | | -Templates are directories containing a `.devcontainer/devcontainer.json` file. They live in `~/.local/share/dev-code/templates/` by default (XDG-compliant), or wherever `$DEVCODE_TEMPLATE_DIR` points. |
| 165 | +# Show all containers (including stopped) |
| 166 | +devcode ps -a |
157 | 167 |
|
158 | | -### Get started |
| 168 | +# Interactive project switcher |
| 169 | +devcode ps -a -i |
| 170 | +``` |
| 171 | + |
| 172 | +Select a container to reopen its project in VS Code. |
| 173 | + |
| 174 | +--- |
| 175 | + |
| 176 | +## Templates in practice |
159 | 177 |
|
160 | 178 | ```bash |
161 | | -devcode init # copies the built-in dev-code template |
162 | | -devcode new my-python # creates a new template from the default base |
163 | | -devcode new my-node dev-code # creates a new template based on dev-code |
164 | | -devcode edit my-python # open the template in VS Code to customise it |
| 179 | +devcode init |
| 180 | +devcode new my-python |
| 181 | +devcode edit my-python |
| 182 | +devcode open my-python ~/projects/app |
165 | 183 | ``` |
166 | 184 |
|
167 | | -### File sync — copy files into the container on launch |
| 185 | +--- |
168 | 186 |
|
169 | | -Add a `customizations.dev-code.cp` section to your `devcontainer.json` to copy files from your host into the running container: |
| 187 | +## File Copy (inject files into container) |
170 | 188 |
|
171 | 189 | ```json |
172 | 190 | { |
173 | 191 | "customizations": { |
174 | 192 | "dev-code": { |
175 | 193 | "cp": [ |
176 | 194 | { |
177 | | - "source": "${localEnv:HOME}/.claude/credentials.json", |
178 | | - "target": "/home/vscode/.claude/credentials.json" |
| 195 | + "source": "${localEnv:HOME}/.config/myapp", |
| 196 | + "target": "/home/vscode/.config/myapp" |
179 | 197 | } |
180 | 198 | ] |
181 | 199 | } |
182 | 200 | } |
183 | 201 | } |
184 | 202 | ``` |
185 | 203 |
|
186 | | -| Field | Type | Default | Description | |
187 | | -|---|---|---|---| |
188 | | -| `source` | string | required | Host path. Supports `${localEnv:VAR}` and relative paths. Use trailing `/.` to copy directory contents. | |
189 | | -| `target` | string | required | Container path. Trailing `/` places the source inside the directory. | |
190 | | -| `override` | bool | `false` | When `true`, overwrite an existing target. When `false` (default), skip if target already exists. | |
191 | | -| `owner` | string | — | User for `chown -R owner:group` after copy. Both `owner` and `group` must be set; silently skipped if either is omitted. | |
192 | | -| `group` | string | — | Group for `chown`. Both `owner` and `group` must be set; silently skipped if either is omitted. | |
193 | | -| `permissions` | string | — | Mode for `chmod -R` after copy (e.g. `"600"`). | |
| 204 | +Perfect for: |
194 | 205 |
|
195 | | -All field names are lowercase. |
| 206 | +* Credentials |
| 207 | +* Config files |
| 208 | +* Local development secrets |
196 | 209 |
|
197 | 210 | --- |
198 | 211 |
|
199 | | -## Contributing |
| 212 | +## Shell completion |
200 | 213 |
|
201 | | -Contributions are welcome! To get started: |
| 214 | +### Bash |
202 | 215 |
|
203 | 216 | ```bash |
204 | | -git clone https://github.com/dacrystal/dev-code |
205 | | -devcode open dev-code ./dev-code |
| 217 | +eval "$(devcode completion bash)" |
206 | 218 | ``` |
207 | 219 |
|
208 | | -The repo includes a `dev-code` devcontainer — open it with itself. |
| 220 | +### Zsh |
| 221 | + |
| 222 | +```zsh |
| 223 | +eval "$(devcode completion zsh)" |
| 224 | +``` |
| 225 | + |
| 226 | +> Requires `devcode` to be installed (not via alias). |
| 227 | +
|
| 228 | +--- |
| 229 | + |
| 230 | +## How it works |
209 | 231 |
|
210 | | -Please open an issue before submitting large changes. |
| 232 | +* Resolve a template |
| 233 | +* Launch VS Code with a devcontainer |
| 234 | +* Apply optional file sync rules |
| 235 | + |
| 236 | +--- |
| 237 | + |
| 238 | +## Contributing |
| 239 | + |
| 240 | +```bash |
| 241 | +git clone https://github.com/dacrystal/dev-code |
| 242 | +devcode open dev-code ./dev-code |
| 243 | +``` |
211 | 244 |
|
212 | 245 | --- |
213 | 246 |
|
|
0 commit comments