turbo-editors/turbo-gopublic Fork 0
85cf23f
Commits
Clone
git clone https://git.rickub.com/turbo-editors/turbo-go.git
git clone ssh://git@rickub.com/turbo-editors/turbo-go.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

📦 Turbo Go

k33g committed 2026-09-20T09:16:06+02:00 Browse files
85cf23f parent: 145937a
added .memory/handoffs/2026-09-20-load-config.md +22 -0
new file mode 100644
@@ -0,0 +1,22 @@
1+# Handoff — 2026-09-20 — `-load-config` (needs turbo-core v1.0.3)
2+
3+## State
4+
5+- `-load-config <url>` wired in `main.go`, three tests in `main_test.go`, docs EN+FR updated. Green under the umbrella `go.work` (`turbo-editors/`), which resolves turbo-core to the local checkout.
6+- **`go.mod` still says turbo-core v1.0.2** — `GOWORK=off make check` fails until turbo-core v1.0.3 is tagged and this is re-pinned. Even under the workspace, the two release-script tests (`TestTheTagScript…`) fail for the same reason: they build a copy of the module outside it. Everything else is green.
7+
8+## Next steps
9+
10+1. When turbo-core v1.0.3 is tagged: `go get rickub.com/turbo-editors/turbo-core@v1.0.3 && go mod tidy && GOWORK=off make check`.
11+2. Try it for real: in an empty directory, `turbo-go -load-config https://rickub.com/turbo-editors/configs/tree/main/golang-init` (the sample repository holds `.turbo-go` only — for this editor a directory with a `.turbo-go` is needed), then start `turbo-go` and check the settings took.
12+3. Then `./01-release.tag.sh` as usual.
13+
14+## Traps
15+
16+- The sample configs repository is `rickub.com/turbo-editors/configs`; its git address is `git.rickub.com`, which `configrepo` tries second. A wrong first candidate costs one `ls-remote`, not the load.
17+- The editor refuses when `.turbo-go` already exists (`configrepo.ErrExists`); there is deliberately no `--force`.
18+
19+## Observed at the end of the session
20+
21+`demo/README.md`, `demo/go.mod`, `demo/index.html`, `demo/index.js`, `demo/main.go` are deleted in the working tree (`git status` shows `D`), and an untracked `demo-golang` binary (6.9 MB) sits at the module root. No test or script here deletes `demo/` (grep of `*.sh`, `Makefile`, `*_test.go`), the reflog shows no git operation, and the folder is kDrive-synced — most likely something done on the host. Not restored by this session; `git checkout -- demo` brings the files back if that was not intended. Note `demo/go.mod` is also what a root `go.work` must list to run `go` inside `demo/`.
22+
new file mode 100644
@@ -0,0 +1,22 @@
1+# Handoff — 2026-09-20 — `-load-config` (needs turbo-core v1.0.3)
2+
3+## State
4+
5+- `-load-config <url>` wired in `main.go`, three tests in `main_test.go`, docs EN+FR updated. Green under the umbrella `go.work` (`turbo-editors/`), which resolves turbo-core to the local checkout.
6+- **`go.mod` still says turbo-core v1.0.2** — `GOWORK=off make check` fails until turbo-core v1.0.3 is tagged and this is re-pinned. Even under the workspace, the two release-script tests (`TestTheTagScript…`) fail for the same reason: they build a copy of the module outside it. Everything else is green.
7+
8+## Next steps
9+
10+1. When turbo-core v1.0.3 is tagged: `go get rickub.com/turbo-editors/turbo-core@v1.0.3 && go mod tidy && GOWORK=off make check`.
11+2. Try it for real: in an empty directory, `turbo-go -load-config https://rickub.com/turbo-editors/configs/tree/main/golang-init` (the sample repository holds `.turbo-go` only — for this editor a directory with a `.turbo-go` is needed), then start `turbo-go` and check the settings took.
12+3. Then `./01-release.tag.sh` as usual.
13+
14+## Traps
15+
16+- The sample configs repository is `rickub.com/turbo-editors/configs`; its git address is `git.rickub.com`, which `configrepo` tries second. A wrong first candidate costs one `ls-remote`, not the load.
17+- The editor refuses when `.turbo-go` already exists (`configrepo.ErrExists`); there is deliberately no `--force`.
18+
19+## Observed at the end of the session
20+
21+`demo/README.md`, `demo/go.mod`, `demo/index.html`, `demo/index.js`, `demo/main.go` are deleted in the working tree (`git status` shows `D`), and an untracked `demo-golang` binary (6.9 MB) sits at the module root. No test or script here deletes `demo/` (grep of `*.sh`, `Makefile`, `*_test.go`), the reflog shows no git operation, and the folder is kDrive-synced — most likely something done on the host. Not restored by this session; `git checkout -- demo` brings the files back if that was not intended. Note `demo/go.mod` is also what a root `go.work` must list to run `go` inside `demo/`.
22+
modified .memory/history.md +9 -0
@@ -515,3 +515,12 @@
515515 - **Asked**: rename the build script, now that `02` and `04` are gone and the numbering had a hole.
516516 - **Changes**: `git mv`-equivalent rename; every reference rewritten — `01-release.tag.sh`, `.github/workflows/release.yml`, `Makefile` (the `ldflags` target's comment), `release_test.go`, `release.env`, `docs/{en,fr}/how-to/make-a-release.md`, `docs/{en,fr}/reference/versioning.md`, `.memory/summary.md`. Older history entries and handoffs keep the old name, as history does.
517517 - **Tests**: `GOWORK=off make check` green.
518+
519+## 2026-09-20 — `-load-config <url>`: a shared `.turbo-go` fetched from a repository
520+
521+- **Asked** (umbrella session, ticket #25 of `turbo-editors/.tickets`): `turbo-go --load-config <forge URL>` fetches the `.turbo-go` found at that directory of the repository and copies it into the working directory; the same for every Turbo editor with its own directory name.
522+- **Changes**: `main.go` — `loadConfig` option and flag, `case opts.loadConfig != ""` in `run`, `loadConfig` and `describeLoad`; the work itself is turbo-core's new `configrepo` package (git ls-remote + shallow clone; rickub, GitHub, GitLab, Codeberg URLs). `main_test.go` — three tests (`describeLoad` ×2, `loadConfig` refuses when `.turbo-go` exists, no network needed). Docs: `docs/{en,fr}/reference/cli.md` (flag, example, files, errors), `docs/{en,fr}/how-to/configure-a-project.md` (new section).
523+- **Depends on turbo-core v1.0.3**, not yet tagged: `go.mod` still pins v1.0.2, so this builds only under the umbrella `go.work` (`turbo-editors/README.md` explains) until `go get rickub.com/turbo-editors/turbo-core@v1.0.3 && go mod tidy`. Verified with `make check` under that workspace.
524+- **Not done**: not committed; go.mod not re-pinned; not run against a real terminal.
525+- **Correction, same session**: under the workspace everything passes **except `TestTheTagScriptTagsAndPushesForReal` and `TestTheTagScriptRefusesATagItAlreadyPublished`** — they copy the module elsewhere and run `make check` there, outside the workspace, where turbo-core v1.0.2 from the proxy has no `configrepo`. They go green the moment `go.mod` is re-pinned to v1.0.3. The package diagram (`docs/diagrams/packages.drawio`, where the module has one) gained a `configrepo` box and a `main → configrepo` arrow, which its own test demanded.
526+
@@ -515,3 +515,12 @@
515 - **Asked**: rename the build script, now that `02` and `04` are gone and the numbering had a hole.515 - **Asked**: rename the build script, now that `02` and `04` are gone and the numbering had a hole.
516 - **Changes**: `git mv`-equivalent rename; every reference rewritten — `01-release.tag.sh`, `.github/workflows/release.yml`, `Makefile` (the `ldflags` target's comment), `release_test.go`, `release.env`, `docs/{en,fr}/how-to/make-a-release.md`, `docs/{en,fr}/reference/versioning.md`, `.memory/summary.md`. Older history entries and handoffs keep the old name, as history does.516 - **Changes**: `git mv`-equivalent rename; every reference rewritten — `01-release.tag.sh`, `.github/workflows/release.yml`, `Makefile` (the `ldflags` target's comment), `release_test.go`, `release.env`, `docs/{en,fr}/how-to/make-a-release.md`, `docs/{en,fr}/reference/versioning.md`, `.memory/summary.md`. Older history entries and handoffs keep the old name, as history does.
517 - **Tests**: `GOWORK=off make check` green.517 - **Tests**: `GOWORK=off make check` green.
518+
519+## 2026-09-20 — `-load-config <url>`: a shared `.turbo-go` fetched from a repository
520+
521+- **Asked** (umbrella session, ticket #25 of `turbo-editors/.tickets`): `turbo-go --load-config <forge URL>` fetches the `.turbo-go` found at that directory of the repository and copies it into the working directory; the same for every Turbo editor with its own directory name.
522+- **Changes**: `main.go` — `loadConfig` option and flag, `case opts.loadConfig != ""` in `run`, `loadConfig` and `describeLoad`; the work itself is turbo-core's new `configrepo` package (git ls-remote + shallow clone; rickub, GitHub, GitLab, Codeberg URLs). `main_test.go` — three tests (`describeLoad` ×2, `loadConfig` refuses when `.turbo-go` exists, no network needed). Docs: `docs/{en,fr}/reference/cli.md` (flag, example, files, errors), `docs/{en,fr}/how-to/configure-a-project.md` (new section).
523+- **Depends on turbo-core v1.0.3**, not yet tagged: `go.mod` still pins v1.0.2, so this builds only under the umbrella `go.work` (`turbo-editors/README.md` explains) until `go get rickub.com/turbo-editors/turbo-core@v1.0.3 && go mod tidy`. Verified with `make check` under that workspace.
524+- **Not done**: not committed; go.mod not re-pinned; not run against a real terminal.
525+- **Correction, same session**: under the workspace everything passes **except `TestTheTagScriptTagsAndPushesForReal` and `TestTheTagScriptRefusesATagItAlreadyPublished`** — they copy the module elsewhere and run `make check` there, outside the workspace, where turbo-core v1.0.2 from the proxy has no `configrepo`. They go green the moment `go.mod` is re-pinned to v1.0.3. The package diagram (`docs/diagrams/packages.drawio`, where the module has one) gained a `configrepo` box and a `main → configrepo` arrow, which its own test demanded.
526+
modified .memory/summary.md +5 -0
@@ -207,3 +207,8 @@ Reports land in `.quality/`; exit code 0 = pass.
207207 - **Autosave has never been used for a whole working session.** It was verified end to end in a pty, but nobody has yet spent an hour editing with it on, which is where a save at an unwanted moment would show up.
208208 - **The window boxes have not been clicked by a human.** Both were verified by rendering the real binary through the project's own VT emulator — the frame reads `[x] … 1═[■]`, Window ▸ Maximise flips it to `[▬]` and fills the terminal, and a second use restores it — but nobody has yet pressed either box with an actual mouse.
209209 - **`ui.Menu` has no nested submenus.** `MenuItem` has no `Items` field, so the project-settings entries are two flat items under Options rather than the submenu originally asked for. Adding nesting is a `ui` change nobody has asked for yet.
210+
211+## State as of 2026-09-20
212+
213+- **`-load-config <url>` is wired** (`main.go`: `loadConfig`, `describeLoad`), on top of turbo-core's `configrepo`. It needs **turbo-core v1.0.3**, which is not tagged yet; `go.mod` pins v1.0.2, so the editor builds only under the umbrella `go.work` until re-pinned. A project with a `.turbo-go` already is refused, not overwritten.
214+
@@ -207,3 +207,8 @@ Reports land in `.quality/`; exit code 0 = pass.
207 - **Autosave has never been used for a whole working session.** It was verified end to end in a pty, but nobody has yet spent an hour editing with it on, which is where a save at an unwanted moment would show up.207 - **Autosave has never been used for a whole working session.** It was verified end to end in a pty, but nobody has yet spent an hour editing with it on, which is where a save at an unwanted moment would show up.
208 - **The window boxes have not been clicked by a human.** Both were verified by rendering the real binary through the project's own VT emulator — the frame reads `[x] … 1═[■]`, Window ▸ Maximise flips it to `[▬]` and fills the terminal, and a second use restores it — but nobody has yet pressed either box with an actual mouse.208 - **The window boxes have not been clicked by a human.** Both were verified by rendering the real binary through the project's own VT emulator — the frame reads `[x] … 1═[■]`, Window ▸ Maximise flips it to `[▬]` and fills the terminal, and a second use restores it — but nobody has yet pressed either box with an actual mouse.
209 - **`ui.Menu` has no nested submenus.** `MenuItem` has no `Items` field, so the project-settings entries are two flat items under Options rather than the submenu originally asked for. Adding nesting is a `ui` change nobody has asked for yet.209 - **`ui.Menu` has no nested submenus.** `MenuItem` has no `Items` field, so the project-settings entries are two flat items under Options rather than the submenu originally asked for. Adding nesting is a `ui` change nobody has asked for yet.
210+
211+## State as of 2026-09-20
212+
213+- **`-load-config <url>` is wired** (`main.go`: `loadConfig`, `describeLoad`), on top of turbo-core's `configrepo`. It needs **turbo-core v1.0.3**, which is not tagged yet; `go.mod` pins v1.0.2, so the editor builds only under the umbrella `go.work` until re-pinned. A project with a `.turbo-go` already is refused, not overwritten.
214+
added INSTALL.MACOS.md +11 -0
new file mode 100644
@@ -0,0 +1,11 @@
1+# Install `turbo-go` on macOS
2+
3+```bash
4+# download the binary release in https://rickub.com/turbo-editors/turbo-go/releases
5+VERSION=1.0.3
6+curl -fsSLO https://rickub.com/turbo-editors/turbo-go/releases/download/v${VERSION}/turbo-go-${VERSION}-darwin-arm64
7+chmod +x ./turbo-go-${VERSION}-darwin-arm64
8+xattr -cr ./turbo-go-${VERSION}-darwin-arm64
9+sudo rm /usr/local/bin/turbo-go
10+sudo cp ./turbo-go-${VERSION}-darwin-arm64 /usr/local/bin/turbo-go
11+```
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,11 @@
1+# Install `turbo-go` on macOS
2+
3+```bash
4+# download the binary release in https://rickub.com/turbo-editors/turbo-go/releases
5+VERSION=1.0.3
6+curl -fsSLO https://rickub.com/turbo-editors/turbo-go/releases/download/v${VERSION}/turbo-go-${VERSION}-darwin-arm64
7+chmod +x ./turbo-go-${VERSION}-darwin-arm64
8+xattr -cr ./turbo-go-${VERSION}-darwin-arm64
9+sudo rm /usr/local/bin/turbo-go
10+sudo cp ./turbo-go-${VERSION}-darwin-arm64 /usr/local/bin/turbo-go
11+```
\ No newline at end of file\ No newline at end of file
deleted demo/README.md +0 -12
deleted file mode 100644
@@ -1,12 +0,0 @@
1-## This a test
2-
3-**Hello**
4-
5-I'm bob
6-
7-```golang
8-// this is a remark
9-
10-```
11-
12-
deleted file mode 100644
@@ -1,12 +0,0 @@
1-## This a test
2-
3-**Hello**
4-
5-I'm bob
6-
7-```golang
8-// this is a remark
9-
10-```
11-
12-
deleted demo/go.mod +0 -3
deleted file mode 100644
@@ -1,3 +0,0 @@
1-module hello
2-
3-go 1.26.5
deleted file mode 100644
@@ -1,3 +0,0 @@
1-module hello
2-
3-go 1.26.5
deleted demo/index.html +0 -4
deleted file mode 100644
@@ -1,4 +0,0 @@
1-<body id="yolo">
2- this is a test...
3- hello world 😄
4-</body>
\ No newline at end of file
deleted file mode 100644
@@ -1,4 +0,0 @@
1-<body id="yolo">
2- this is a test...
3- hello world 😄
4-</body>
\ No newline at end of file\ No newline at end of file
deleted demo/index.js +0 -9
deleted file mode 100644
@@ -1,9 +0,0 @@
1-// hello
2-
3-console.log("hello I'm Bob")
4-
5-function hello(name) {
6- // this is a function
7- return `Hello ${name}`
8-
9-}
\ No newline at end of file
deleted file mode 100644
@@ -1,9 +0,0 @@
1-// hello
2-
3-console.log("hello I'm Bob")
4-
5-function hello(name) {
6- // this is a function
7- return `Hello ${name}`
8-
9-}
\ No newline at end of file\ No newline at end of file
deleted demo/main.go +0 -13
deleted file mode 100644
@@ -1,13 +0,0 @@
1-package main
2-
3-import "fmt"
4-
5-func main() {
6-
7- fmt.Println("hello")
8- fmt.Println("world 😉 ")
9- fmt.Println("I'm Bob")
10- fmt.Println("I'm Philippe")
11-
12-}
13-
deleted file mode 100644
@@ -1,13 +0,0 @@
1-package main
2-
3-import "fmt"
4-
5-func main() {
6-
7- fmt.Println("hello")
8- fmt.Println("world 😉 ")
9- fmt.Println("I'm Bob")
10- fmt.Println("I'm Philippe")
11-
12-}
13-
modified docs/en/how-to/configure-a-project.md +13 -0
@@ -70,6 +70,19 @@ turbo-go -theme turbo-dark main.go
7070
7171 **Options ▸ Project settings…** opens it again. It is greyed out in a project that has none.
7272
73+## Start from a shared configuration
74+
75+A team can keep ready-made configurations in a repository — one directory per kind of project, each with a `.turbo-go` inside. Point the editor at the directory, with the URL the browser shows, and it copies that `.turbo-go` into the current directory:
76+
77+```bash
78+cd my-project
79+turbo-go -load-config https://rickub.com/turbo-editors/configs/tree/main/golang-init
80+```
81+
82+It prints what arrived and exits; the next `turbo-go` opens the project with those settings, snippets and tools in force. The URL may be on rickub, GitHub, GitLab or Codeberg, and may point at the directory, at the `.turbo-go` inside it, or at the repository itself for its root on the default branch. `git` must be installed: the fetch is a shallow clone.
83+
84+A project that already has a `.turbo-go` is left alone — the editor refuses rather than overwrite what the project decided. Move the directory away first if you mean to replace it.
85+
7386 ## Variants
7487
7588 - **You start the editor from a subdirectory.** The settings are not found: only `./.turbo-go` is looked at, with no walk up towards the project root. Start from the project's own directory, or pass `-theme` for that run.
@@ -70,6 +70,19 @@ turbo-go -theme turbo-dark main.go
70 70
71 **Options ▸ Project settings…** opens it again. It is greyed out in a project that has none.71 **Options ▸ Project settings…** opens it again. It is greyed out in a project that has none.
72 72
73+## Start from a shared configuration
74+
75+A team can keep ready-made configurations in a repository — one directory per kind of project, each with a `.turbo-go` inside. Point the editor at the directory, with the URL the browser shows, and it copies that `.turbo-go` into the current directory:
76+
77+```bash
78+cd my-project
79+turbo-go -load-config https://rickub.com/turbo-editors/configs/tree/main/golang-init
80+```
81+
82+It prints what arrived and exits; the next `turbo-go` opens the project with those settings, snippets and tools in force. The URL may be on rickub, GitHub, GitLab or Codeberg, and may point at the directory, at the `.turbo-go` inside it, or at the repository itself for its root on the default branch. `git` must be installed: the fetch is a shallow clone.
83+
84+A project that already has a `.turbo-go` is left alone — the editor refuses rather than overwrite what the project decided. Move the directory away first if you mean to replace it.
85+
73 ## Variants86 ## Variants
74 87
75 - **You start the editor from a subdirectory.** The settings are not found: only `./.turbo-go` is looked at, with no walk up towards the project root. Start from the project's own directory, or pass `-theme` for that run.88 - **You start the editor from a subdirectory.** The settings are not found: only `./.turbo-go` is looked at, with no walk up towards the project root. Start from the project's own directory, or pass `-theme` for that run.
modified docs/en/reference/cli.md +7 -0
@@ -18,6 +18,7 @@ Each `file` is opened in its own window. A file that does not exist yet is opene
1818 | `-list-themes` | bool | `false` | Print every loadable theme with its description, then the user theme directory, and exit. |
1919 | `-no-lsp` | bool | `false` | Do not start a language server. Colouring and editing are unaffected. |
2020 | `-version` | bool | `false` | Print `Turbo Go <version>` on one line, with the commit and build date when the build recorded them, and exit. See [the version number](versioning.md). |
21+| `-load-config <url>` | string | none | Copy the `.turbo-go` directory found at a repository URL — rickub, GitHub, GitLab or Codeberg, the URL of the directory as the browser shows it — into the working directory, print what arrived, and exit. Needs `git`. Refuses when `./.turbo-go` already exists. The editor is not started. |
2122 | `-h`, `-help` | bool | `false` | Print the flag list and exit. |
2223
2324 ## Environment
@@ -34,6 +35,7 @@ Each `file` is opened in its own window. A file that does not exist yet is opene
3435 | --- | --- |
3536 | `$TURBO_GO_THEME_DIR/*.toml` | User themes, when the variable is set. |
3637 | `./.turbo-go/settings.toml` | This project's settings, read once at start-up. See [project settings](project-settings.md). |
38+| `./.turbo-go/` (written) | Created by `-load-config` from a repository's copy, when the project has none yet. |
3739 | `~/.config/turbo-go/themes/*.toml` | User themes on Linux (`os.UserConfigDir`). |
3840 | `~/Library/Application Support/turbo-go/themes/*.toml` | User themes on macOS. |
3941 | `<module>/go.mod` | Located by walking up from the first file; its directory becomes the language server's root. |
@@ -72,6 +74,7 @@ turbo-go main.go go.mod # two windows
7274 turbo-go -theme turbo-dark main.go # a different theme
7375 turbo-go -no-lsp main.go # no language server
7476 turbo-go -list-themes # what themes exist
77+turbo-go -load-config https://rickub.com/turbo-editors/configs/tree/main/golang-init # start from a shared configuration
7578 ```
7679
7780 ## Installer
@@ -98,3 +101,7 @@ turbo-go -list-themes # what themes exist
98101 | `turbo-go: initialising the terminal: …` | The terminal was opened but could not be put into raw mode. |
99102 | `Cannot open` (in a dialog) | The path is a directory, or is not readable. |
100103 | `Cannot save` (in a dialog) | The directory does not exist, or is not writable. |
104+| `turbo-go: configrepo: the project already has a configuration directory: …` | `-load-config` into a project that already has `.turbo-go`. Move it away first. |
105+| `turbo-go: configrepo: git is not installed` | `-load-config` needs the `git` command on `PATH`. |
106+| `turbo-go: configrepo: no configuration directory at that path: …` | The repository was found but holds no `.turbo-go` where the URL points. |
107+| `turbo-go: configrepo: no repository answered: …` | No clone address for that URL answered; the URL, the network, or a private repository. |
@@ -18,6 +18,7 @@ Each `file` is opened in its own window. A file that does not exist yet is opene
18 | `-list-themes` | bool | `false` | Print every loadable theme with its description, then the user theme directory, and exit. |18 | `-list-themes` | bool | `false` | Print every loadable theme with its description, then the user theme directory, and exit. |
19 | `-no-lsp` | bool | `false` | Do not start a language server. Colouring and editing are unaffected. |19 | `-no-lsp` | bool | `false` | Do not start a language server. Colouring and editing are unaffected. |
20 | `-version` | bool | `false` | Print `Turbo Go <version>` on one line, with the commit and build date when the build recorded them, and exit. See [the version number](versioning.md). |20 | `-version` | bool | `false` | Print `Turbo Go <version>` on one line, with the commit and build date when the build recorded them, and exit. See [the version number](versioning.md). |
21+| `-load-config <url>` | string | none | Copy the `.turbo-go` directory found at a repository URL — rickub, GitHub, GitLab or Codeberg, the URL of the directory as the browser shows it — into the working directory, print what arrived, and exit. Needs `git`. Refuses when `./.turbo-go` already exists. The editor is not started. |
21 | `-h`, `-help` | bool | `false` | Print the flag list and exit. |22 | `-h`, `-help` | bool | `false` | Print the flag list and exit. |
22 23
23 ## Environment24 ## Environment
@@ -34,6 +35,7 @@ Each `file` is opened in its own window. A file that does not exist yet is opene
34 | --- | --- |35 | --- | --- |
35 | `$TURBO_GO_THEME_DIR/*.toml` | User themes, when the variable is set. |36 | `$TURBO_GO_THEME_DIR/*.toml` | User themes, when the variable is set. |
36 | `./.turbo-go/settings.toml` | This project's settings, read once at start-up. See [project settings](project-settings.md). |37 | `./.turbo-go/settings.toml` | This project's settings, read once at start-up. See [project settings](project-settings.md). |
38+| `./.turbo-go/` (written) | Created by `-load-config` from a repository's copy, when the project has none yet. |
37 | `~/.config/turbo-go/themes/*.toml` | User themes on Linux (`os.UserConfigDir`). |39 | `~/.config/turbo-go/themes/*.toml` | User themes on Linux (`os.UserConfigDir`). |
38 | `~/Library/Application Support/turbo-go/themes/*.toml` | User themes on macOS. |40 | `~/Library/Application Support/turbo-go/themes/*.toml` | User themes on macOS. |
39 | `<module>/go.mod` | Located by walking up from the first file; its directory becomes the language server's root. |41 | `<module>/go.mod` | Located by walking up from the first file; its directory becomes the language server's root. |
@@ -72,6 +74,7 @@ turbo-go main.go go.mod # two windows
72 turbo-go -theme turbo-dark main.go # a different theme74 turbo-go -theme turbo-dark main.go # a different theme
73 turbo-go -no-lsp main.go # no language server75 turbo-go -no-lsp main.go # no language server
74 turbo-go -list-themes # what themes exist76 turbo-go -list-themes # what themes exist
77+turbo-go -load-config https://rickub.com/turbo-editors/configs/tree/main/golang-init # start from a shared configuration
75 ```78 ```
76 79
77 ## Installer80 ## Installer
@@ -98,3 +101,7 @@ turbo-go -list-themes # what themes exist
98 | `turbo-go: initialising the terminal: …` | The terminal was opened but could not be put into raw mode. |101 | `turbo-go: initialising the terminal: …` | The terminal was opened but could not be put into raw mode. |
99 | `Cannot open` (in a dialog) | The path is a directory, or is not readable. |102 | `Cannot open` (in a dialog) | The path is a directory, or is not readable. |
100 | `Cannot save` (in a dialog) | The directory does not exist, or is not writable. |103 | `Cannot save` (in a dialog) | The directory does not exist, or is not writable. |
104+| `turbo-go: configrepo: the project already has a configuration directory: …` | `-load-config` into a project that already has `.turbo-go`. Move it away first. |
105+| `turbo-go: configrepo: git is not installed` | `-load-config` needs the `git` command on `PATH`. |
106+| `turbo-go: configrepo: no configuration directory at that path: …` | The repository was found but holds no `.turbo-go` where the URL points. |
107+| `turbo-go: configrepo: no repository answered: …` | No clone address for that URL answered; the URL, the network, or a private repository. |
modified docs/fr/how-to/configure-a-project.md +13 -0
@@ -70,6 +70,19 @@ turbo-go -theme turbo-dark main.go
7070
7171 **Options ▸ Project settings…** le rouvre. L'entrée est grisée dans un projet qui n'en a pas.
7272
73+## Partir d'une configuration partagée
74+
75+Une équipe peut garder des configurations toutes prêtes dans un dépôt — un dossier par sorte de projet, chacun avec un `.turbo-go` dedans. Donnez à l'éditeur l'URL du dossier, telle que le navigateur l'affiche, et il copie ce `.turbo-go` dans le répertoire courant :
76+
77+```bash
78+cd mon-projet
79+turbo-go -load-config https://rickub.com/turbo-editors/configs/tree/main/golang-init
80+```
81+
82+Il affiche ce qui est arrivé et quitte ; le `turbo-go` suivant ouvre le projet avec ces réglages, extraits et outils en vigueur. L'URL peut être sur rickub, GitHub, GitLab ou Codeberg, et pointer sur le dossier, sur le `.turbo-go` qu'il contient, ou sur le dépôt lui-même pour sa racine sur la branche par défaut. `git` doit être installé : la récupération est un clone superficiel.
83+
84+Un projet qui a déjà un `.turbo-go` est laissé tel quel — l'éditeur refuse plutôt que d'écraser ce que le projet a décidé. Déplacez d'abord le dossier si vous voulez le remplacer.
85+
7386 ## Variantes
7487
7588 - **Vous lancez l'éditeur depuis un sous-dossier.** Les réglages ne sont pas trouvés : seul `./.turbo-go` est consulté, sans remontée vers la racine du projet. Lancez depuis le dossier du projet, ou passez `-theme` pour cette fois.
@@ -70,6 +70,19 @@ turbo-go -theme turbo-dark main.go
70 70
71 **Options ▸ Project settings…** le rouvre. L'entrée est grisée dans un projet qui n'en a pas.71 **Options ▸ Project settings…** le rouvre. L'entrée est grisée dans un projet qui n'en a pas.
72 72
73+## Partir d'une configuration partagée
74+
75+Une équipe peut garder des configurations toutes prêtes dans un dépôt — un dossier par sorte de projet, chacun avec un `.turbo-go` dedans. Donnez à l'éditeur l'URL du dossier, telle que le navigateur l'affiche, et il copie ce `.turbo-go` dans le répertoire courant :
76+
77+```bash
78+cd mon-projet
79+turbo-go -load-config https://rickub.com/turbo-editors/configs/tree/main/golang-init
80+```
81+
82+Il affiche ce qui est arrivé et quitte ; le `turbo-go` suivant ouvre le projet avec ces réglages, extraits et outils en vigueur. L'URL peut être sur rickub, GitHub, GitLab ou Codeberg, et pointer sur le dossier, sur le `.turbo-go` qu'il contient, ou sur le dépôt lui-même pour sa racine sur la branche par défaut. `git` doit être installé : la récupération est un clone superficiel.
83+
84+Un projet qui a déjà un `.turbo-go` est laissé tel quel — l'éditeur refuse plutôt que d'écraser ce que le projet a décidé. Déplacez d'abord le dossier si vous voulez le remplacer.
85+
73 ## Variantes86 ## Variantes
74 87
75 - **Vous lancez l'éditeur depuis un sous-dossier.** Les réglages ne sont pas trouvés : seul `./.turbo-go` est consulté, sans remontée vers la racine du projet. Lancez depuis le dossier du projet, ou passez `-theme` pour cette fois.88 - **Vous lancez l'éditeur depuis un sous-dossier.** Les réglages ne sont pas trouvés : seul `./.turbo-go` est consulté, sans remontée vers la racine du projet. Lancez depuis le dossier du projet, ou passez `-theme` pour cette fois.
modified docs/fr/reference/cli.md +7 -0
@@ -18,6 +18,7 @@ Chaque `fichier` est ouvert dans sa propre fenêtre. Un fichier qui n'existe pas
1818 | `-list-themes` | booléen | `false` | Affiche chaque thème chargeable avec sa description, puis le répertoire de thèmes utilisateur, et quitte. |
1919 | `-no-lsp` | booléen | `false` | Ne démarre pas de serveur de langage. La coloration et l'édition sont inchangées. |
2020 | `-version` | booléen | `false` | Affiche `Turbo Go <version>` sur une ligne, avec le commit et la date de build quand le build les a enregistrés, puis quitte. Voir [le numéro de version](versioning.md). |
21+| `-load-config <url>` | chaîne | aucune | Copie le répertoire `.turbo-go` trouvé à l'URL d'un dépôt — rickub, GitHub, GitLab ou Codeberg, l'URL du dossier telle que le navigateur l'affiche — dans le répertoire courant, affiche ce qui est arrivé, et quitte. Nécessite `git`. Refuse si `./.turbo-go` existe déjà. L'éditeur n'est pas lancé. |
2122 | `-h`, `-help` | booléen | `false` | Affiche la liste des options et quitte. |
2223
2324 ## Environnement
@@ -34,6 +35,7 @@ Chaque `fichier` est ouvert dans sa propre fenêtre. Un fichier qui n'existe pas
3435 | --- | --- |
3536 | `$TURBO_GO_THEME_DIR/*.toml` | Thèmes utilisateur, quand la variable est définie. |
3637 | `./.turbo-go/settings.toml` | Les réglages de ce projet, lus une fois au démarrage. Voir [réglages de projet](project-settings.md). |
38+| `./.turbo-go/` (écrit) | Créé par `-load-config` à partir de la copie d'un dépôt, quand le projet n'en a pas encore. |
3739 | `~/.config/turbo-go/themes/*.toml` | Thèmes utilisateur sous Linux (`os.UserConfigDir`). |
3840 | `~/Library/Application Support/turbo-go/themes/*.toml` | Thèmes utilisateur sous macOS. |
3941 | `<module>/go.mod` | Trouvé en remontant depuis le premier fichier ; son répertoire devient la racine du serveur de langage. |
@@ -72,6 +74,7 @@ turbo-go main.go go.mod # deux fenêtres
7274 turbo-go -theme turbo-dark main.go # un autre thème
7375 turbo-go -no-lsp main.go # sans serveur de langage
7476 turbo-go -list-themes # quels thèmes existent
77+turbo-go -load-config https://rickub.com/turbo-editors/configs/tree/main/golang-init # partir d'une configuration partagée
7578 ```
7679
7780 ## Installateur
@@ -98,3 +101,7 @@ turbo-go -list-themes # quels thèmes existent
98101 | `turbo-go: initialising the terminal: …` | Le terminal a été ouvert mais n'a pas pu être mis en mode brut. |
99102 | `Cannot open` (dans une boîte) | Le chemin est un répertoire, ou n'est pas lisible. |
100103 | `Cannot save` (dans une boîte) | Le répertoire n'existe pas, ou n'est pas accessible en écriture. |
104+| `turbo-go: configrepo: the project already has a configuration directory: …` | `-load-config` dans un projet qui a déjà `.turbo-go`. Déplacez-le d'abord. |
105+| `turbo-go: configrepo: git is not installed` | `-load-config` a besoin de la commande `git` dans le `PATH`. |
106+| `turbo-go: configrepo: no configuration directory at that path: …` | Le dépôt existe mais ne contient pas de `.turbo-go` là où l'URL pointe. |
107+| `turbo-go: configrepo: no repository answered: …` | Aucune adresse de clone pour cette URL n'a répondu : l'URL, le réseau, ou un dépôt privé. |
@@ -18,6 +18,7 @@ Chaque `fichier` est ouvert dans sa propre fenêtre. Un fichier qui n'existe pas
18 | `-list-themes` | booléen | `false` | Affiche chaque thème chargeable avec sa description, puis le répertoire de thèmes utilisateur, et quitte. |18 | `-list-themes` | booléen | `false` | Affiche chaque thème chargeable avec sa description, puis le répertoire de thèmes utilisateur, et quitte. |
19 | `-no-lsp` | booléen | `false` | Ne démarre pas de serveur de langage. La coloration et l'édition sont inchangées. |19 | `-no-lsp` | booléen | `false` | Ne démarre pas de serveur de langage. La coloration et l'édition sont inchangées. |
20 | `-version` | booléen | `false` | Affiche `Turbo Go <version>` sur une ligne, avec le commit et la date de build quand le build les a enregistrés, puis quitte. Voir [le numéro de version](versioning.md). |20 | `-version` | booléen | `false` | Affiche `Turbo Go <version>` sur une ligne, avec le commit et la date de build quand le build les a enregistrés, puis quitte. Voir [le numéro de version](versioning.md). |
21+| `-load-config <url>` | chaîne | aucune | Copie le répertoire `.turbo-go` trouvé à l'URL d'un dépôt — rickub, GitHub, GitLab ou Codeberg, l'URL du dossier telle que le navigateur l'affiche — dans le répertoire courant, affiche ce qui est arrivé, et quitte. Nécessite `git`. Refuse si `./.turbo-go` existe déjà. L'éditeur n'est pas lancé. |
21 | `-h`, `-help` | booléen | `false` | Affiche la liste des options et quitte. |22 | `-h`, `-help` | booléen | `false` | Affiche la liste des options et quitte. |
22 23
23 ## Environnement24 ## Environnement
@@ -34,6 +35,7 @@ Chaque `fichier` est ouvert dans sa propre fenêtre. Un fichier qui n'existe pas
34 | --- | --- |35 | --- | --- |
35 | `$TURBO_GO_THEME_DIR/*.toml` | Thèmes utilisateur, quand la variable est définie. |36 | `$TURBO_GO_THEME_DIR/*.toml` | Thèmes utilisateur, quand la variable est définie. |
36 | `./.turbo-go/settings.toml` | Les réglages de ce projet, lus une fois au démarrage. Voir [réglages de projet](project-settings.md). |37 | `./.turbo-go/settings.toml` | Les réglages de ce projet, lus une fois au démarrage. Voir [réglages de projet](project-settings.md). |
38+| `./.turbo-go/` (écrit) | Créé par `-load-config` à partir de la copie d'un dépôt, quand le projet n'en a pas encore. |
37 | `~/.config/turbo-go/themes/*.toml` | Thèmes utilisateur sous Linux (`os.UserConfigDir`). |39 | `~/.config/turbo-go/themes/*.toml` | Thèmes utilisateur sous Linux (`os.UserConfigDir`). |
38 | `~/Library/Application Support/turbo-go/themes/*.toml` | Thèmes utilisateur sous macOS. |40 | `~/Library/Application Support/turbo-go/themes/*.toml` | Thèmes utilisateur sous macOS. |
39 | `<module>/go.mod` | Trouvé en remontant depuis le premier fichier ; son répertoire devient la racine du serveur de langage. |41 | `<module>/go.mod` | Trouvé en remontant depuis le premier fichier ; son répertoire devient la racine du serveur de langage. |
@@ -72,6 +74,7 @@ turbo-go main.go go.mod # deux fenêtres
72 turbo-go -theme turbo-dark main.go # un autre thème74 turbo-go -theme turbo-dark main.go # un autre thème
73 turbo-go -no-lsp main.go # sans serveur de langage75 turbo-go -no-lsp main.go # sans serveur de langage
74 turbo-go -list-themes # quels thèmes existent76 turbo-go -list-themes # quels thèmes existent
77+turbo-go -load-config https://rickub.com/turbo-editors/configs/tree/main/golang-init # partir d'une configuration partagée
75 ```78 ```
76 79
77 ## Installateur80 ## Installateur
@@ -98,3 +101,7 @@ turbo-go -list-themes # quels thèmes existent
98 | `turbo-go: initialising the terminal: …` | Le terminal a été ouvert mais n'a pas pu être mis en mode brut. |101 | `turbo-go: initialising the terminal: …` | Le terminal a été ouvert mais n'a pas pu être mis en mode brut. |
99 | `Cannot open` (dans une boîte) | Le chemin est un répertoire, ou n'est pas lisible. |102 | `Cannot open` (dans une boîte) | Le chemin est un répertoire, ou n'est pas lisible. |
100 | `Cannot save` (dans une boîte) | Le répertoire n'existe pas, ou n'est pas accessible en écriture. |103 | `Cannot save` (dans une boîte) | Le répertoire n'existe pas, ou n'est pas accessible en écriture. |
104+| `turbo-go: configrepo: the project already has a configuration directory: …` | `-load-config` dans un projet qui a déjà `.turbo-go`. Déplacez-le d'abord. |
105+| `turbo-go: configrepo: git is not installed` | `-load-config` a besoin de la commande `git` dans le `PATH`. |
106+| `turbo-go: configrepo: no configuration directory at that path: …` | Le dépôt existe mais ne contient pas de `.turbo-go` là où l'URL pointe. |
107+| `turbo-go: configrepo: no repository answered: …` | Aucune adresse de clone pour cette URL n'a répondu : l'URL, le réseau, ou un dépôt privé. |
modified go.mod +1 -1
@@ -4,7 +4,7 @@ go 1.26.1
44
55 require (
66 github.com/gdamore/tcell/v2 v2.13.10
7- rickub.com/turbo-editors/turbo-core v1.0.2
7+ rickub.com/turbo-editors/turbo-core v1.0.3
88 )
99
1010 require (
@@ -4,7 +4,7 @@ go 1.26.1
4 4
5 require (5 require (
6 github.com/gdamore/tcell/v2 v2.13.106 github.com/gdamore/tcell/v2 v2.13.10
7- rickub.com/turbo-editors/turbo-core v1.0.27+ rickub.com/turbo-editors/turbo-core v1.0.3
8 )8 )
9 9
10 require (10 require (
modified go.sum +2 -2
@@ -45,5 +45,5 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn
4545 golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
4646 golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
4747 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
48-rickub.com/turbo-editors/turbo-core v1.0.2 h1:OA/LhR6JkvtUlp6lTgYa0wwaWou3HKXd1Glnoscyffw=
49-rickub.com/turbo-editors/turbo-core v1.0.2/go.mod h1:rmfIY5gsFEo3sC5IIJFapwsGvdKG6NjrD7ACmnNTKq8=
48+rickub.com/turbo-editors/turbo-core v1.0.3 h1:j+bqzIIBsese8iLgre9PQdbpi9YkoOMIHP6pOli5UjE=
49+rickub.com/turbo-editors/turbo-core v1.0.3/go.mod h1:rmfIY5gsFEo3sC5IIJFapwsGvdKG6NjrD7ACmnNTKq8=
@@ -45,5 +45,5 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn
45 golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=45 golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
46 golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=46 golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
47 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=47 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
48-rickub.com/turbo-editors/turbo-core v1.0.2 h1:OA/LhR6JkvtUlp6lTgYa0wwaWou3HKXd1Glnoscyffw=48+rickub.com/turbo-editors/turbo-core v1.0.3 h1:j+bqzIIBsese8iLgre9PQdbpi9YkoOMIHP6pOli5UjE=
49-rickub.com/turbo-editors/turbo-core v1.0.2/go.mod h1:rmfIY5gsFEo3sC5IIJFapwsGvdKG6NjrD7ACmnNTKq8=49+rickub.com/turbo-editors/turbo-core v1.0.3/go.mod h1:rmfIY5gsFEo3sC5IIJFapwsGvdKG6NjrD7ACmnNTKq8=
modified main.go +38 -0
@@ -15,6 +15,7 @@
1515 // -list-themes print the available themes and exit
1616 // -no-lsp do not start a language server
1717 // -version print the version and exit
18+// -load-config url copy the .turbo-go directory found at a repository URL into the working directory and exit
1819 package main
1920
2021 import (
@@ -23,10 +24,12 @@ import (
2324 "flag"
2425 "fmt"
2526 "os"
27+ "strings"
2628
2729 "github.com/gdamore/tcell/v2"
2830
2931 "rickub.com/turbo-editors/turbo-core/app"
32+ "rickub.com/turbo-editors/turbo-core/configrepo"
3033 "rickub.com/turbo-editors/turbo-core/profile"
3134 "rickub.com/turbo-editors/turbo-core/settings"
3235 "rickub.com/turbo-editors/turbo-core/theme"
@@ -46,6 +49,7 @@ func main() {
4649 type options struct {
4750 theme string
4851 listThemes bool
52+ loadConfig string
4953 noLSP bool
5054 version bool
5155 files []string
@@ -62,6 +66,7 @@ func parseFlags() options {
6266 flag.BoolVar(&opts.listThemes, "list-themes", false, "print the available themes and exit")
6367 flag.BoolVar(&opts.noLSP, "no-lsp", false, "do not start a language server")
6468 flag.BoolVar(&opts.version, "version", false, "print the version and exit")
69+ flag.StringVar(&opts.loadConfig, "load-config", "", "copy the .turbo-go directory found at this repository URL into the working directory, then exit")
6570 flag.Parse()
6671
6772 opts.files = flag.Args()
@@ -82,6 +87,8 @@ func run() error {
8287 return nil
8388 case opts.listThemes:
8489 return listThemes(p)
90+ case opts.loadConfig != "":
91+ return loadConfig(p, opts.loadConfig)
8592 }
8693
8794 return edit(opts, p)
@@ -106,6 +113,37 @@ func listThemes(p profile.Profile) error {
106113 return nil
107114 }
108115
116+// loadConfig copies a shared configuration — the .turbo-go directory at a
117+// repository URL, on rickub, GitHub, GitLab or Codeberg — into the working
118+// directory, and says what arrived. The editor is not started: this is a
119+// set-up step, and the next command is the one that opens the project.
120+//
121+// A project that already has a .turbo-go is left alone; turbo-core refuses
122+// rather than overwrite what the project decided.
123+func loadConfig(p profile.Profile, url string) error {
124+ result, err := configrepo.Load(context.Background(), p, url, ".")
125+ if err != nil {
126+ return err
127+ }
128+ fmt.Print(describeLoad(result))
129+ return nil
130+}
131+
132+// describeLoad is what a successful -load-config prints: where the files
133+// came from, and each of them, so the reader knows what is now in force.
134+func describeLoad(result configrepo.Result) string {
135+ var out strings.Builder
136+ fmt.Fprintf(&out, "Copied %s from %s", result.Dir, result.Remote)
137+ if result.Ref != "" {
138+ fmt.Fprintf(&out, " (%s)", result.Ref)
139+ }
140+ out.WriteString(":\n")
141+ for _, file := range result.Files {
142+ fmt.Fprintf(&out, " %s\n", file)
143+ }
144+ return out.String()
145+}
146+
109147 // edit opens the terminal and runs the editor until the user leaves.
110148 func edit(opts options, p profile.Profile) error {
111149 project, projectSettings := loadProjectSettings(p)
@@ -15,6 +15,7 @@
15 // -list-themes print the available themes and exit15 // -list-themes print the available themes and exit
16 // -no-lsp do not start a language server16 // -no-lsp do not start a language server
17 // -version print the version and exit17 // -version print the version and exit
18+// -load-config url copy the .turbo-go directory found at a repository URL into the working directory and exit
18 package main19 package main
19 20
20 import (21 import (
@@ -23,10 +24,12 @@ import (
23 "flag"24 "flag"
24 "fmt"25 "fmt"
25 "os"26 "os"
27+ "strings"
26 28
27 "github.com/gdamore/tcell/v2"29 "github.com/gdamore/tcell/v2"
28 30
29 "rickub.com/turbo-editors/turbo-core/app"31 "rickub.com/turbo-editors/turbo-core/app"
32+ "rickub.com/turbo-editors/turbo-core/configrepo"
30 "rickub.com/turbo-editors/turbo-core/profile"33 "rickub.com/turbo-editors/turbo-core/profile"
31 "rickub.com/turbo-editors/turbo-core/settings"34 "rickub.com/turbo-editors/turbo-core/settings"
32 "rickub.com/turbo-editors/turbo-core/theme"35 "rickub.com/turbo-editors/turbo-core/theme"
@@ -46,6 +49,7 @@ func main() {
46 type options struct {49 type options struct {
47 theme string50 theme string
48 listThemes bool51 listThemes bool
52+ loadConfig string
49 noLSP bool53 noLSP bool
50 version bool54 version bool
51 files []string55 files []string
@@ -62,6 +66,7 @@ func parseFlags() options {
62 flag.BoolVar(&opts.listThemes, "list-themes", false, "print the available themes and exit")66 flag.BoolVar(&opts.listThemes, "list-themes", false, "print the available themes and exit")
63 flag.BoolVar(&opts.noLSP, "no-lsp", false, "do not start a language server")67 flag.BoolVar(&opts.noLSP, "no-lsp", false, "do not start a language server")
64 flag.BoolVar(&opts.version, "version", false, "print the version and exit")68 flag.BoolVar(&opts.version, "version", false, "print the version and exit")
69+ flag.StringVar(&opts.loadConfig, "load-config", "", "copy the .turbo-go directory found at this repository URL into the working directory, then exit")
65 flag.Parse()70 flag.Parse()
66 71
67 opts.files = flag.Args()72 opts.files = flag.Args()
@@ -82,6 +87,8 @@ func run() error {
82 return nil87 return nil
83 case opts.listThemes:88 case opts.listThemes:
84 return listThemes(p)89 return listThemes(p)
90+ case opts.loadConfig != "":
91+ return loadConfig(p, opts.loadConfig)
85 }92 }
86 93
87 return edit(opts, p)94 return edit(opts, p)
@@ -106,6 +113,37 @@ func listThemes(p profile.Profile) error {
106 return nil113 return nil
107 }114 }
108 115
116+// loadConfig copies a shared configuration — the .turbo-go directory at a
117+// repository URL, on rickub, GitHub, GitLab or Codeberg — into the working
118+// directory, and says what arrived. The editor is not started: this is a
119+// set-up step, and the next command is the one that opens the project.
120+//
121+// A project that already has a .turbo-go is left alone; turbo-core refuses
122+// rather than overwrite what the project decided.
123+func loadConfig(p profile.Profile, url string) error {
124+ result, err := configrepo.Load(context.Background(), p, url, ".")
125+ if err != nil {
126+ return err
127+ }
128+ fmt.Print(describeLoad(result))
129+ return nil
130+}
131+
132+// describeLoad is what a successful -load-config prints: where the files
133+// came from, and each of them, so the reader knows what is now in force.
134+func describeLoad(result configrepo.Result) string {
135+ var out strings.Builder
136+ fmt.Fprintf(&out, "Copied %s from %s", result.Dir, result.Remote)
137+ if result.Ref != "" {
138+ fmt.Fprintf(&out, " (%s)", result.Ref)
139+ }
140+ out.WriteString(":\n")
141+ for _, file := range result.Files {
142+ fmt.Fprintf(&out, " %s\n", file)
143+ }
144+ return out.String()
145+}
146+
109 // edit opens the terminal and runs the editor until the user leaves.147 // edit opens the terminal and runs the editor until the user leaves.
110 func edit(opts options, p profile.Profile) error {148 func edit(opts options, p profile.Profile) error {
111 project, projectSettings := loadProjectSettings(p)149 project, projectSettings := loadProjectSettings(p)
modified main_test.go +41 -0
@@ -1,11 +1,14 @@
11 package main
22
33 import (
4+ "errors"
45 "os"
56 "path/filepath"
7+ "strings"
68 "testing"
79
810 "rickub.com/turbo-editors/turbo-core/app"
11+ "rickub.com/turbo-editors/turbo-core/configrepo"
912 "rickub.com/turbo-editors/turbo-core/settings"
1013 "rickub.com/turbo-editors/turbo-core/theme"
1114
@@ -129,3 +132,41 @@ func TestABrokenSettingsFileDoesNotStopTheEditor(t *testing.T) {
129132 t.Errorf("loadProjectSettings(golang.Profile()) = %+v, want the defaults", loaded)
130133 }
131134 }
135+
136+func TestDescribeLoadNamesTheSourceAndEveryFile(t *testing.T) {
137+ got := describeLoad(configrepo.Result{
138+ Remote: "https://git.rickub.com/turbo-editors/configs.git",
139+ Ref: "main",
140+ Dir: "/work/.turbo-go",
141+ Files: []string{"settings.toml", "tools.toml"},
142+ })
143+
144+ want := "Copied /work/.turbo-go from https://git.rickub.com/turbo-editors/configs.git (main):\n settings.toml\n tools.toml\n"
145+ if got != want {
146+ t.Errorf("describeLoad() =\n%q\nwant\n%q", got, want)
147+ }
148+}
149+
150+func TestDescribeLoadOmitsTheRefWhenTheDefaultBranchWasUsed(t *testing.T) {
151+ got := describeLoad(configrepo.Result{Remote: "r", Dir: "d"})
152+
153+ if strings.Contains(got, "(") {
154+ t.Errorf("describeLoad() = %q, want no parenthesised ref", got)
155+ }
156+}
157+
158+func TestLoadConfigLeavesAProjectThatHasAConfigurationAlone(t *testing.T) {
159+ // Checked before anything is fetched, so this needs neither git nor a
160+ // network: the project's own .turbo-go is a decision, not a default.
161+ project := t.TempDir()
162+ if err := os.MkdirAll(filepath.Join(project, ".turbo-go"), 0o755); err != nil {
163+ t.Fatal(err)
164+ }
165+ t.Chdir(project)
166+
167+ err := loadConfig(golang.Profile(), "https://rickub.com/turbo-editors/configs/tree/main/golang-init")
168+
169+ if !errors.Is(err, configrepo.ErrExists) {
170+ t.Errorf("loadConfig() error = %v, want ErrExists", err)
171+ }
172+}
@@ -1,11 +1,14 @@
1 package main1 package main
2 2
3 import (3 import (
4+ "errors"
4 "os"5 "os"
5 "path/filepath"6 "path/filepath"
7+ "strings"
6 "testing"8 "testing"
7 9
8 "rickub.com/turbo-editors/turbo-core/app"10 "rickub.com/turbo-editors/turbo-core/app"
11+ "rickub.com/turbo-editors/turbo-core/configrepo"
9 "rickub.com/turbo-editors/turbo-core/settings"12 "rickub.com/turbo-editors/turbo-core/settings"
10 "rickub.com/turbo-editors/turbo-core/theme"13 "rickub.com/turbo-editors/turbo-core/theme"
11 14
@@ -129,3 +132,41 @@ func TestABrokenSettingsFileDoesNotStopTheEditor(t *testing.T) {
129 t.Errorf("loadProjectSettings(golang.Profile()) = %+v, want the defaults", loaded)132 t.Errorf("loadProjectSettings(golang.Profile()) = %+v, want the defaults", loaded)
130 }133 }
131 }134 }
135+
136+func TestDescribeLoadNamesTheSourceAndEveryFile(t *testing.T) {
137+ got := describeLoad(configrepo.Result{
138+ Remote: "https://git.rickub.com/turbo-editors/configs.git",
139+ Ref: "main",
140+ Dir: "/work/.turbo-go",
141+ Files: []string{"settings.toml", "tools.toml"},
142+ })
143+
144+ want := "Copied /work/.turbo-go from https://git.rickub.com/turbo-editors/configs.git (main):\n settings.toml\n tools.toml\n"
145+ if got != want {
146+ t.Errorf("describeLoad() =\n%q\nwant\n%q", got, want)
147+ }
148+}
149+
150+func TestDescribeLoadOmitsTheRefWhenTheDefaultBranchWasUsed(t *testing.T) {
151+ got := describeLoad(configrepo.Result{Remote: "r", Dir: "d"})
152+
153+ if strings.Contains(got, "(") {
154+ t.Errorf("describeLoad() = %q, want no parenthesised ref", got)
155+ }
156+}
157+
158+func TestLoadConfigLeavesAProjectThatHasAConfigurationAlone(t *testing.T) {
159+ // Checked before anything is fetched, so this needs neither git nor a
160+ // network: the project's own .turbo-go is a decision, not a default.
161+ project := t.TempDir()
162+ if err := os.MkdirAll(filepath.Join(project, ".turbo-go"), 0o755); err != nil {
163+ t.Fatal(err)
164+ }
165+ t.Chdir(project)
166+
167+ err := loadConfig(golang.Profile(), "https://rickub.com/turbo-editors/configs/tree/main/golang-init")
168+
169+ if !errors.Is(err, configrepo.ErrExists) {
170+ t.Errorf("loadConfig() error = %v, want ErrExists", err)
171+ }
172+}