Skip to content

Commit ed702a6

Browse files
authored
Hello CONFIG! Not task runner - just config - but with aliases (#202)
1 parent 7a739d3 commit ed702a6

File tree

6 files changed

+589
-43
lines changed

6 files changed

+589
-43
lines changed

README.md

Lines changed: 151 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ As a result, your colleagues would not have to install anything on their host ma
3636
## Features
3737

3838
- **Zero dependencies** - Works on minimal containers (Alpine, Ubuntu) without curl/wget or CA certificates
39+
- **Configuration system** - Define version requirements and command aliases via `gg.toml` files
3940
- Simplify the management of other executables in your project
4041
- Automatically detect and execute the required executable version using project configuration files (such
4142
as `package.json` for Node.js projects)
@@ -49,6 +50,83 @@ Windows).
4950
Use the `-l` flag to use a local cache (`.cache/gg` in current directory) instead.
5051
Adds every dependency into `PATH` before executing.
5152

53+
## Configuration
54+
55+
`gg.cmd` supports project-specific configuration via a `gg.toml` file. This allows you to define version requirements
56+
and command aliases for your project.
57+
58+
Note, this is not a full task runner, if you need a full task runner, consider using [just](https://just.systems/),
59+
60+
### Creating a Configuration File
61+
62+
Create a `gg.toml` configuration file in your project root:
63+
64+
```bash
65+
./gg.cmd config init
66+
```
67+
68+
This creates a `gg.toml` file with the following structure:
69+
70+
```toml
71+
# gg configuration file
72+
# See https://github.com/eirikb/gg for more information
73+
74+
[dependencies]
75+
# Define version requirements for tools
76+
# Examples:
77+
# node = "^18.0.0"
78+
# java = "17"
79+
# gradle = "~7.6.0"
80+
81+
[aliases]
82+
# Define command shortcuts
83+
# Examples:
84+
# build = "gradle clean build"
85+
# serve = "node@18 server.js"
86+
# test = "npm test"
87+
```
88+
89+
### Configuration Features
90+
91+
**Version Dependencies**: Ensure team members use compatible tool versions
92+
93+
```toml
94+
[dependencies]
95+
node = "^18.0.0" # Allow 18.x.x versions
96+
java = "17" # Require exactly Java 17
97+
gradle = "~7.6.0" # Allow 7.6.x versions
98+
```
99+
100+
**Command Aliases**: Create shortcuts for common commands
101+
102+
```toml
103+
[aliases]
104+
build = "gradle clean build"
105+
serve = "node@18 server.js --port 3000"
106+
test = "npm test"
107+
gen = "dart scripts/generate.dart"
108+
```
109+
110+
### Using Aliases
111+
112+
Once defined, aliases can be used directly:
113+
114+
```bash
115+
./gg.cmd build # Expands to: ./gg.cmd gradle clean build
116+
./gg.cmd serve --dev # Expands to: ./gg.cmd node@18 server.js --port 3000 --dev
117+
./gg.cmd test --coverage # Expands to: ./gg.cmd npm test --coverage
118+
```
119+
120+
### Viewing Configuration
121+
122+
View your current configuration:
123+
124+
```bash
125+
./gg.cmd config show
126+
```
127+
128+
This will display the configuration file location, its contents, and parsed aliases/dependencies.
129+
52130
## Usage
53131

54132
Using `gg.cmd` is easy. Simply place the executable in the root of your project and run it with the `gg.cmd` command
@@ -74,16 +152,27 @@ Options:
74152
-vv Debug output
75153
-vvv Trace output
76154
-w Even more output
155+
-h, --help Print help
77156
-V, --version Print version
78157
--os <OS> Override target OS (windows, linux, mac)
79158
--arch <ARCH> Override target architecture (x86_64, arm64, armv7)
80159
81160
Built in commands:
82-
update Update gg.cmd
161+
update Check for updates for all tools (including gg)
162+
update -u Update all tools that have updates available
163+
update <tool> Check for updates for specific tool (e.g., update flutter, update gg)
164+
update <tool> -u Update specific tool (e.g., update flutter -u, update gg -u)
165+
update <tool> -u -f Force update specific tool even if up to date (e.g., update gg -u -f)
83166
help Print help
84-
check Check for updates
85-
check-update Check for updates and update if available
167+
tools List all available tools
86168
clean-cache Clean cache (prompts for confirmation)
169+
config init Create a new gg.toml configuration file
170+
config show Show current configuration
171+
172+
Update options:
173+
-u Actually perform the update (vs just checking)
174+
-f Force re-download even if already up to date (use with -u)
175+
--major Include major version updates (default: skip major versions)
87176
88177
Version syntax:
89178
@X Any X.y.z version (e.g. node@14 for any Node.js 14.x.y)
@@ -93,30 +182,42 @@ Version syntax:
93182
@~X.Y.Z X.Y.Z or any newer patch version (tilde prefix)
94183
@=X.Y.Z Exactly X.Y.Z version (equals prefix, same as X.Y.Z without prefix)
95184
96-
Supported tools:
97-
node (npm, npx will also work, version refers to node version)
98-
gradle
99-
java
100-
jbang
101-
maven (mvn)
102-
bld
103-
openapi
104-
rat (ra)
105-
deno
106-
go
107-
caddy
108-
just
109-
fortio
110-
flutter (dart will also work)
111-
run (any arbitrary command)
112-
gh/<owner>/<repo> (GitHub releases)
185+
Examples:
186+
./gg.cmd node
187+
./gg.cmd -l node (use local cache)
188+
./gg.cmd gradle@6:java@17 clean build
189+
./gg.cmd -l gradle@6:java@17 clean build (use local cache)
190+
./gg.cmd node@10 -e 'console.log(1)'
191+
./gg.cmd [email protected] -v
192+
./gg.cmd -vv -w npm@14 start
193+
./gg.cmd java@-jdk+jre -version
194+
./gg.cmd jbang hello.java
195+
./gg.cmd bld version
196+
./gg.cmd maven compile
197+
./gg.cmd run:java@17 soapui
198+
./gg.cmd run:java@14 env
199+
./gg.cmd update
200+
./gg.cmd gh/cli/cli --version
201+
./gg.cmd --os windows --arch x86_64 deno --version (test Windows Deno on Linux)
202+
./gg.cmd --os mac deno --help (test macOS Deno from anywhere)
203+
204+
Example tools:
205+
node Node.js JavaScript runtime (npm, npx will also work)
206+
java Java runtime and development kit
207+
gradle Gradle build automation tool
208+
go Go programming language
209+
flutter Flutter SDK (dart will also work)
210+
211+
Run 'gg tools' to see all available tools with descriptions
212+
213+
GitHub repos can be accessed directly:
214+
gh/<owner>/<repo> Any GitHub release (e.g. gh/cli/cli)
113215
114216
Available tags by tools:
115217
java: +jdk, +jre, +lts, +sts, +mts, +ea, +ga, +headless, +headfull, +fx, +normal, +hotspot (defaults: +jdk, +ga)
116218
node: +lts
117219
go: +beta (excluded by default)
118220
openapi: +beta (excluded by default)
119-
flutter: +beta (excluded by default)
120221
```
121222

122223
## Node
@@ -230,6 +331,35 @@ gh version 2.73.0 (2025-05-19)
230331
https://github.com/cli/cli/releases/tag/v2.73.0
231332
```
232333

334+
### Using Configuration and Aliases
335+
336+
Create a `gg.toml` configuration file:
337+
338+
```bash
339+
./gg.cmd config init
340+
```
341+
342+
Add some aliases and dependencies:
343+
344+
```toml
345+
[dependencies]
346+
node = "^18.0.0"
347+
gradle = "~7.6.0"
348+
349+
[aliases]
350+
dev = "node@18 server.js --dev"
351+
build = "gradle clean build"
352+
test = "npm test --coverage"
353+
```
354+
355+
Now use the aliases:
356+
357+
```bash
358+
./gg.cmd dev # Runs: ./gg.cmd node@18 server.js --dev
359+
./gg.cmd build --parallel # Runs: ./gg.cmd gradle clean build --parallel
360+
./gg.cmd test # Runs: ./gg.cmd npm test --coverage
361+
```
362+
233363
## Cache Management
234364

235365
`gg.cmd` supports both global and local cache modes:

src/stage4/Cargo.lock

Lines changed: 58 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/stage4/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ serde-java-properties = "0.2.0"
3030
sha256 = "1.2.2"
3131
tempfile = "3.8"
3232
ctrlc = "3.4"
33+
toml = "0.9.5"
34+
shlex = "1.3.0"

0 commit comments

Comments
 (0)