Skip to content

Commit 2ff4576

Browse files
committed
Merge branch 'main' into 0.3.0
2 parents 79a14fa + 257b928 commit 2ff4576

File tree

2 files changed

+43
-26
lines changed

2 files changed

+43
-26
lines changed

.env.example

+15-12
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,26 @@
22
# This file is used to store environment variables for the application
33
# It is not meant to be checked into version control
44

5-
# Section
5+
# Another section
66
#
7-
# Description of REQUIRED_VARIABLE
8-
REQUIRED_VARIABLE=
9-
# REQUIRED_VARIABLE=EXAMPLE_VALUE_1
10-
# REQUIRED_VARIABLE=EXAMPLE_VALUE_2
11-
# REQUIRED_VARIABLE_FILE=/run/secrets/required_variable
7+
# Description of OPTIONAL_VARIABLE_WITH_DEFAULT
8+
# OPTIONAL_VARIABLE_WITH_DEFAULT=EXAMPLE_VALUE_1
9+
# OPTIONAL_VARIABLE_WITH_DEFAULT=EXAMPLE_VALUE_2
10+
#
11+
# OPTIONAL_VARIABLE_WITH_DEFAULT_FILE=/run/secrets/optional_variable_with_default
12+
13+
# Section
1214
#
1315
# Description of OPTIONAL_VARIABLE
1416
# OPTIONAL_VARIABLE=
1517
# OPTIONAL_VARIABLE=EXAMPLE_VALUE_1
1618
# OPTIONAL_VARIABLE=EXAMPLE_VALUE_2
19+
#
1720
# OPTIONAL_VARIABLE_FILE=/run/secrets/optional_variable
18-
19-
# Another section
2021
#
21-
# Description of OPTIONAL_VARIABLE_WITH_DEFAULT
22-
# OPTIONAL_VARIABLE_WITH_DEFAULT=EXAMPLE_VALUE_1
23-
# OPTIONAL_VARIABLE_WITH_DEFAULT=EXAMPLE_VALUE_2
24-
# OPTIONAL_VARIABLE_WITH_DEFAULT_FILE=/run/secrets/optional_variable_with_default
22+
# Description of REQUIRED_VARIABLE
23+
REQUIRED_VARIABLE=
24+
# REQUIRED_VARIABLE=EXAMPLE_VALUE_1
25+
# REQUIRED_VARIABLE=EXAMPLE_VALUE_2
26+
#
27+
# REQUIRED_VARIABLE_FILE=/run/secrets/required_variable

main.ts

+28-14
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,47 @@ if (import.meta.main) {
99
const docs = new Command()
1010
.arguments("<path:file>")
1111
.description("Generate documentation from .env files")
12-
.action(async (_options, path: string) => {
13-
console.log(
14-
await parseAndConvert(
15-
path,
16-
new DocsWriter(),
17-
),
12+
.option("-o, --output <path:string>", "Output file path")
13+
.action(async ({ output }, path) => {
14+
const markdown = await parseAndConvert(
15+
path,
16+
new DocsWriter(),
1817
);
18+
if (output) {
19+
await Deno.writeTextFile(output, markdown);
20+
console.log(`File written: ${output}`);
21+
} else {
22+
console.log(markdown);
23+
}
1924
});
2025

2126
const envExample = new Command()
2227
.arguments("<path:string>")
2328
.description("Generate example .env file")
24-
.action(async (_options, path: string) => {
25-
console.log(
26-
await parseAndConvert(
27-
path,
28-
new EnvExampleWriter(),
29-
),
29+
.option("-r, --replace", "Replace existing .env file")
30+
.option("-o, --output <path:string>", "Output file path")
31+
.action(async ({ replace, output }, path: string) => {
32+
const fileContents = await parseAndConvert(
33+
path,
34+
new EnvExampleWriter(),
3035
);
36+
if (replace || output) {
37+
await Deno.writeTextFile(output ?? path, fileContents);
38+
console.log(`File written: ${output ?? path}`);
39+
} else {
40+
console.log(fileContents);
41+
}
3142
});
3243

3344
await new Command()
3445
.name("envardoc")
3546
.version(metadata.version)
3647
.description(metadata.description)
37-
.meta('Deno', Deno.version.deno)
38-
.meta('FS Read Permissions', Deno.permissions.querySync({ name: "read" }).state)
48+
.meta("Deno", Deno.version.deno)
49+
.meta(
50+
"FS Read Permissions",
51+
Deno.permissions.querySync({ name: "read" }).state,
52+
)
3953
.command("docs", docs)
4054
.command("example", envExample)
4155
.parse(Deno.args);

0 commit comments

Comments
 (0)