Skip to content

Commit

Permalink
bake: update README
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidGamba committed Jun 20, 2024
1 parent 285581b commit 28cba28
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions bake/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

Go Build + Something like Make = Bake ¯\_(ツ)_/¯ 🤷
Bake is a Make like tool that allows you to define and run tasks defined in Go code under a `bake/` dir.
* Tasks have a fully featured argument parser.
* It allows you to see the description of the tasks and subtasks and autocomplete them and their options.
* It also bundles a DAG runner that allows you to make tasks depend on other tasks.
== Getting Started
In any directory, run: `bake _bake init` to create a `bake/` directory with an empty project.
Expand Down Expand Up @@ -84,22 +90,24 @@ Hola
== How does it work?
Bake is a Make like tool that allows you to define and run tasks defined in Go code under a `bake/` dir.
Bake is a Make like tool that allows you to define and run tasks defined in Go code under a `bake/` dir (or a `bakefiles/` dir).
First it searches to see if the current directory is named `bake/`, next it searches for `bake/` inside the current directory, next it searches for `bake/` in the root of the Go project (the `go.mod` file dir) and finally it searches for `bake/` in the root of the Git repo.
First it searches for `bake/` inside the current directory,
next it searches to see if the current directory is named `bake/`,
finally it searches for a `bake/` directory in the parent directories.
This allows to run bake from anywhere in the repo.
Once a `bake/` dir is found, it will parse the AST of the Go files in that directory to find functions that match the proper signature.
It will then generate an entry point file that uses those functions, this file is auto-generated any time your source code changes.
Finally it will compile the binary and run it.
Having a go binary that bake runs allows you to debug your code directly without having to worry about the bake internals.
Having a go binary that bake runs allows you to debug your code directly without having to worry about bake's internals.
The binary is only recompiled if the source code is changed (using https://github.com/DavidGamba/dgtools/tree/master/fsmodtime[fsmodtime]).
The bake binary loads your functions as tasks and subtasks and makes their options available for completion.
The bake binary loads your functions as tasks and subtasks and makes them and their options available for completion.
The bake Task signature is `func(opt *getoptions.GetOpt) getoptions.CommandFn`.
The functions are loaded as `go-getoptions` commands and subcommands, by parsing the comment description.
The functions are loaded as https://github.com/DavidGamba/go-getoptions/tree/master[go-getoptions] commands and subcommands, by parsing the comment description.
For example:
Expand All @@ -114,19 +122,19 @@ If there is no comment found for the function, the function name will be automat
The above function will be generate two commands, one for `say` and one for `hello`.
The description for the `hello` command will be `This is a greeting`.
It also adds the task to the global task map, the task will automatically be added as `say:hello`.
This allows to generate custom task graphs.
Since the tasks are added to the bake command's `go-getoptions` instance, completions are automatically generated.
It also adds the task to the global task map, the task will automatically be added as `say:hello`.
This allows to generate custom task graphs using https://github.com/DavidGamba/go-getoptions/blob/master/dag/README.adoc[go-getoptions DAG].
=== Debugging
Go to the `bake/` directory and run and you should see the `bake` binary.
Go to the `bake/` directory and run `bake` and you should see the `bake` binary.
Set your IDE Debugger to run `./bake` with the proper arguments for your task.
== ROADMAP
* Currently only `opt.String` is supported, add support for all `go-getoptions` types.
* Currently not all `go-getoptions` types are supported.
* Automated cancellation on timeout when passing -t flag.
* Helper for automated cancellation on timeout when passing -t flag.

0 comments on commit 28cba28

Please sign in to comment.