-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathguide.txt
More file actions
64 lines (44 loc) · 2.14 KB
/
guide.txt
File metadata and controls
64 lines (44 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Core Concepts
`gobake` operates on a simple principle: **Your build system should be as robust as your application.**
Instead of relying on fragile shell scripts or complex Makefiles, `gobake` uses:
1. **Engine:** The core Go library that manages tasks and metadata.
2. **Context:** A helper object passed to every task, providing access to the shell, logging, and environment.
3. **Recipe:** The `Recipe.go` file (using `//go:build gobake`) that ties it all together.
# CLI Command Reference
## Project Management
* **`gobake init`**: Initialize a new project in the current directory. Automates `go mod` and dependency setup.
* **`gobake version`**: Show the current version of gobake.
* **`gobake help`**: Show the list of available commands and project tasks.
* **`gobake template <git-url>`**: Clone a repository and initialize it as a gobake project.
## Dependency & Tool Management
* **`gobake add-tool <url>`**: Adds a tool to the `(tools)` list in `recipe.piml`.
* **`gobake remove-tool <url>`**: Removes a tool from `recipe.piml`.
* **`gobake add-dep <url>`**: Adds a library dependency using `go get`.
* **`gobake remove-dep <url>`**: Removes a library dependency.
## Versioning
* **`gobake bump [patch|minor|major]`**: Increments the project version in `recipe.piml`.
# Metadata (`recipe.piml`)
The `recipe.piml` file is the single source of truth for your project.
```piml
(name) my-project
(version) 1.2.3
(authors)
> Fezcode
(tools)
> github.com/swaggo/swag/cmd/swag@latest
```
# Task Management
Tasks are defined in the `Run(*gobake.Engine)` function using `bake.Task(name, description, function)`.
## Task Dependencies
You can define tasks that depend on other tasks using `bake.TaskWithDeps`.
```go
bake.Task("test", "Run tests", func(ctx *gobake.Context) error { ... })
bake.TaskWithDeps("build", "Build app", []string{"test"}, func(ctx *gobake.Context) error { ... })
```
## Cross-Compilation
Use `ctx.BakeBinary(os, arch, output, flags...)` for simple cross-compilation tasks.
```go
bake.Task("release", "Cross-compile", func(ctx *gobake.Context) error {
return ctx.BakeBinary("linux", "amd64", "bin/app")
})
```