Skip to content

Commit 3dfaf38

Browse files
committed
docs: document the generate --config option
1 parent fc300b0 commit 3dfaf38

3 files changed

Lines changed: 37 additions & 9 deletions

File tree

‎README.md‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,19 @@ java -jar sqlcj-cli-0.1.0-SNAPSHOT.jar generate # compile sqlcj.yaml into Java
7272
java -jar sqlcj-cli-0.1.0-SNAPSHOT.jar --help # list the commands
7373
```
7474

75-
`generate` reads `sqlcj.yaml` from the directory it is run in. It exits with
76-
status `0` on success, and with status `1` after printing one diagnostic for
77-
invalid configuration, an unreadable source, or a query it cannot compile.
75+
`generate` reads `sqlcj.yaml` from the directory it is run in.
76+
`--config <path>` names another configuration file, so generation can run from
77+
any working directory:
78+
79+
```bash
80+
java -jar sqlcj-cli-0.1.0-SNAPSHOT.jar generate --config ../project/sqlcj.yaml
81+
```
82+
83+
A relative `--config` value is resolved against the directory the command is
84+
run in, while the relative paths inside the file stay relative to the file's own
85+
directory. `generate` exits with status `0` on success, and with status `1`
86+
after printing one diagnostic for invalid configuration, an unreadable source,
87+
or a query it cannot compile.
7888

7989
## Getting started
8090

‎docs/configuration.md‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,21 @@ The `generate` command reads `sqlcj.yaml` from the directory it is run in:
1212
sqlcj generate
1313
```
1414

15-
There is no configuration-path option and no configuration discovery in parent
16-
directories.
15+
`--config <path>` selects another file, so generation can run from any working
16+
directory:
17+
18+
```bash
19+
sqlcj generate --config ../project/sqlcj.yaml
20+
```
21+
22+
The option defaults to `sqlcj.yaml`, and a relative value is resolved against
23+
the directory the command is run in. Relative paths inside the file are still
24+
resolved against the directory that contains the file, not against the working
25+
directory. A missing or invalid explicit file reports the usual configuration
26+
diagnostic and exits with status `1`; there is no fallback to `sqlcj.yaml`.
27+
28+
There is no short alias, no environment variable, and no configuration
29+
discovery in parent directories.
1730

1831
## Supported Version
1932

@@ -109,8 +122,9 @@ generated/dev/example/generated/AuthorRepository.java
109122
## Path Resolution
110123

111124
A relative `schema`, `queries`, or `java.out` path is resolved against the
112-
directory that contains `sqlcj.yaml`, not against the process working directory
113-
at a later point in time. An absolute path is used as-is.
125+
directory that contains the configuration file, whether that file is the
126+
default `sqlcj.yaml` or one named by `--config`, and not against the process
127+
working directory at a later point in time. An absolute path is used as-is.
114128

115129
Resolved paths are normalized lexically, so `../sql/schema.sql` is supported.
116130
Resolution does not require `java.out` to exist, does not expand `~`,

‎docs/quickstart.md‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ query of `sql/queries.sql`.
153153

154154
`sqlcj generate` reads `sqlcj.yaml` from the directory it is run in, and the
155155
relative paths above are resolved against the directory that contains the file.
156+
`--config <path>` names another file when the command runs from elsewhere.
156157
Generated output therefore belongs in the build directory, where `mvn clean`
157158
removes it. See [Configuration](configuration.md) for the full file format.
158159

@@ -414,8 +415,11 @@ mvn exec:java
414415
generate, so a query that was renamed or removed would otherwise leave a stale
415416
class behind that still compiles.
416417
- `sqlcj generate` is a separate command. It is not bound to the Maven
417-
lifecycle, so it must run after `clean` and before `compile`. It must run from
418-
the project root, because it reads `sqlcj.yaml` from the current directory.
418+
lifecycle, so it must run after `clean` and before `compile`. The commands
419+
above run from the project root, because `generate` reads `sqlcj.yaml` from
420+
the current directory; from another directory, pass
421+
`--config <path to sqlcj.yaml>` instead, and the paths inside the file keep
422+
resolving against the project root.
419423
- `mvn compile` then compiles `src/main/java` together with
420424
`target/generated-sources/sqlcj`.
421425

0 commit comments

Comments
 (0)