Skip to content

Commit d37b8e8

Browse files
committed
chore: Updated examples.
1 parent 89fc78a commit d37b8e8

File tree

4 files changed

+70
-9
lines changed

4 files changed

+70
-9
lines changed

README.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,16 @@ Variables to resolve:
5252
5353
API_TOKEN
5454
source: manual (interactive prompt)
55-
instructions: Create a token in your admin UI and paste it here.
55+
instructions:
56+
Example (GitHub fine-grained personal access token):
57+
1) Go to https://github.com and sign in.
58+
2) Click your avatar (top-right) -> Settings.
59+
3) Scroll to the bottom of the left sidebar -> Developer settings.
60+
4) Personal access tokens -> Fine-grained tokens -> Generate new token.
61+
5) Set an expiration date, limit repository access, and grant least-privilege permissions.
62+
6) Click Generate token and copy it immediately (you won't be able to see it again).
63+
7) Paste the token here when prompted by envgen.
64+
Tip: Store it in a password manager and rotate it regularly.
5665
5766
APP_NAME
5867
source: static
@@ -189,14 +198,21 @@ variables:
189198
production: "{base_url}"
190199

191200
VITE_API_KEY:
192-
description: "API key (local is static; prod comes from Secret Manager)"
201+
description: "API key (prompt locally; prod comes from Secret Manager)"
193202
source_key: API_KEY
203+
source_instructions: |
204+
Example (GitHub fine-grained personal access token):
205+
1) Go to https://github.com and sign in.
206+
2) Click your avatar (top-right) -> Settings.
207+
3) Scroll to the bottom of the left sidebar -> Developer settings.
208+
4) Personal access tokens -> Fine-grained tokens -> Generate new token.
209+
5) Set an expiration date, limit repository access, and grant least-privilege permissions.
210+
6) Click Generate token and copy it immediately (you won't be able to see it again).
211+
7) Save it somewhere secure (you won't be able to view it again later).
194212
environments: [local, production]
195213
resolvers:
196214
- environments: [local]
197-
source: static
198-
values:
199-
local: "API_KEY-local"
215+
source: manual
200216
- environments: [production]
201217
source: gcloud
202218
```

schemas/envgen.sample.yaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ variables:
4343
#
4444
# Common optional fields:
4545
# - sensitive: true|false (defaults to true; controls masking in output)
46-
# - source_instructions: shown for manual sources to help people find the value
46+
# - source_instructions: shown for manual sources to help people find the value (supports multi-line with |)
4747
# - notes: free-form metadata for humans
4848
# - environments: limit a variable to specific environments
4949
# - resolvers: (schema v2) pick different sources per environment
@@ -61,7 +61,16 @@ variables:
6161
API_TOKEN:
6262
description: "API token used for local development."
6363
source: manual
64-
source_instructions: "Create a token in your admin UI and paste it here."
64+
source_instructions: |
65+
Example (GitHub fine-grained personal access token):
66+
1) Go to https://github.com and sign in.
67+
2) Click your avatar (top-right) -> Settings.
68+
3) Scroll to the bottom of the left sidebar -> Developer settings.
69+
4) Personal access tokens -> Fine-grained tokens -> Generate new token.
70+
5) Set an expiration date, limit repository access, and grant least-privilege permissions.
71+
6) Click Generate token and copy it immediately (you won't be able to see it again).
72+
7) Paste the token here when prompted by envgen.
73+
Tip: Store it in a password manager and rotate it regularly.
6574
notes: "Rotate quarterly."
6675

6776
BUILD_ID:

src/commands/pull.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,24 @@ enum ResolveResult {
2424
Failed(String, String), // (var_name, error)
2525
}
2626

27+
fn print_labeled_multiline(indent: &str, label: &str, value: &str) {
28+
let value = value.trim();
29+
if value.is_empty() {
30+
return;
31+
}
32+
33+
let lines: Vec<&str> = value.lines().collect();
34+
if lines.len() == 1 {
35+
println!("{}{}: {}", indent, label, lines[0]);
36+
return;
37+
}
38+
39+
println!("{}{}:", indent, label);
40+
for line in lines {
41+
println!("{} {}", indent, line);
42+
}
43+
}
44+
2745
/// Run the `pull` command: resolve variables and write the .env file.
2846
pub async fn run_pull(opts: PullOptions) -> Result<bool> {
2947
// Parse and validate schema
@@ -162,7 +180,7 @@ pub async fn run_pull(opts: PullOptions) -> Result<bool> {
162180
println!(" source: manual (skipped; use --interactive to prompt)");
163181
}
164182
if let Some(instructions) = &var.source_instructions {
165-
println!(" instructions: {}", instructions.trim());
183+
print_labeled_multiline(" ", "instructions", instructions);
166184
}
167185
println!();
168186
} else {

src/resolver/manual_source.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,24 @@ pub struct ManualResolveOptions<'a> {
1515
pub non_interactive: bool,
1616
}
1717

18+
fn print_labeled_multiline(indent: &str, label: &str, value: &str) {
19+
let value = value.trim();
20+
if value.is_empty() {
21+
return;
22+
}
23+
24+
let lines: Vec<&str> = value.lines().collect();
25+
if lines.len() == 1 {
26+
println!("{}{}: {}", indent, label, lines[0]);
27+
return;
28+
}
29+
30+
println!("{}{}:", indent, label);
31+
for line in lines {
32+
println!("{} {}", indent, line);
33+
}
34+
}
35+
1836
/// Prompt the user for a manual variable value.
1937
/// Returns None if non-interactive mode is enabled.
2038
pub fn resolve_manual(opts: ManualResolveOptions<'_>) -> Result<Option<String>> {
@@ -31,7 +49,7 @@ pub fn resolve_manual(opts: ManualResolveOptions<'_>) -> Result<Option<String>>
3149

3250
if let Some(instructions) = opts.source_instructions {
3351
let expanded = expand_instructions(instructions, &ctx);
34-
println!(" Instructions: {}", expanded.trim());
52+
print_labeled_multiline(" ", "Instructions", &expanded);
3553
}
3654

3755
println!();

0 commit comments

Comments
 (0)