Skip to content

Commit b6feaa7

Browse files
committed
Add documentation about docker install
1 parent edc22c4 commit b6feaa7

3 files changed

Lines changed: 31 additions & 8 deletions

File tree

cmd/mangosql/mangosql.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ Example: mangosql --output db/file.go db/schema.sql`,
3333
Value: "database/client.go",
3434
Usage: "Output file",
3535
},
36+
&cli.BoolFlag{
37+
Name: "inline",
38+
Aliases: []string{"i"},
39+
Usage: "Output to console",
40+
},
3641
&cli.StringFlag{
3742
Name: "package",
3843
Aliases: []string{"p"},
@@ -73,6 +78,7 @@ Example: mangosql --output db/file.go db/schema.sql`,
7378
return generate(GenerateOptions{
7479
Src: name,
7580
Output: ctx.String("output"),
81+
Inline: ctx.Bool("inline"),
7682
Package: ctx.String("package"),
7783
Driver: driver,
7884
Logger: logger,
@@ -88,6 +94,7 @@ Example: mangosql --output db/file.go db/schema.sql`,
8894
type GenerateOptions struct {
8995
Src string
9096
Output string
97+
Inline bool
9198
Package string
9299
Driver string
93100
Logger string
@@ -153,20 +160,24 @@ func generate(opts GenerateOptions) error {
153160
return err
154161
}
155162

156-
f, err := os.Create(path.Join(folder, file))
163+
contents.Flush()
164+
formatted, err := format.Source([]byte((b.String())))
157165
if err != nil {
158166
return err
159167
}
160168

161-
defer f.Close()
162-
163-
contents.Flush()
169+
if opts.Inline {
170+
fmt.Println(string(formatted))
171+
return nil
172+
}
164173

165-
formatted, err := format.Source([]byte((b.String())))
174+
f, err := os.Create(path.Join(folder, file))
166175
if err != nil {
167176
return err
168177
}
169178

179+
defer f.Close()
180+
170181
_, err = f.WriteString(string(formatted))
171182
fmt.Printf("Generated %s\n", path.Join(folder, file))
172183

devenv.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ in {
99

1010
# Golang
1111
pkgs-unstable.go_1_23
12-
pkgs.gotools
13-
pkgs.golangci-lint
14-
pkgs.gocover-cobertura
12+
pkgs-unstable.gotools
13+
pkgs-unstable.golangci-lint
14+
pkgs-unstable.gocover-cobertura
1515

1616
# NodeJS (docs)
1717
pkgs.nodejs_20

docs/getting-started/index.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ go install github.com/kefniark/mango-sql/cmd/mangosql
1414
mangosql schema.sql
1515
```
1616

17+
```sh [docker]
18+
# Download from docker registry: https://github.com/kefniark/mango-sql/pkgs/container/mango-sql
19+
20+
# Use MangoSQL CLI
21+
docker run -it -v [MOUNT FOLDER]:/app/ ghcr.io/kefniark/mango-sql:latest -i /app/[YOUR SQL FILE] > [OUTPUT GO FILE]
22+
23+
# Example
24+
docker run -it -v .:/app/ ghcr.io/kefniark/mango-sql:latest -i /app/schema.sql > client.go
25+
26+
# -i/--inline: allow to get the generated code without dealing with volume mount and permission issues
27+
```
28+
1729
```sh [manual]
1830
# Download the last release from https://github.com/kefniark/mango-sql/releases
1931

0 commit comments

Comments
 (0)