Skip to content
This repository was archived by the owner on Apr 17, 2025. It is now read-only.

Commit 03ca865

Browse files
doy-striperyan-lane
authored andcommitted
fix trailing newline handling (#7)
* don't always add a newline when writing to stdout this is making stdout have different output behavior than writing to files * also don't auto-chomp templates
1 parent 5a57f0e commit 03ca865

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

confidant_client/formatter.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@ def get_source(self, environment, template):
118118
return source, template, lambda: False
119119

120120
combined_credentials = combined_credential_pair_format(data)
121-
env = jinja2.Environment(loader=GlobalFileLoader())
121+
env = jinja2.Environment(
122+
loader=GlobalFileLoader(),
123+
keep_trailing_newline=True
124+
)
122125
template = env.get_template(template_file)
123126
return template.render(secrets=combined_credentials['credentials'])
124127

@@ -211,7 +214,7 @@ def main():
211214
logging.error('Unsupported --out-format.')
212215
sys.exit(1)
213216
if args.out == '-':
214-
print ret
217+
sys.stdout.write(ret)
215218
else:
216219
with open(os.path.join(args.out), 'w') as f:
217220
f.write(ret)

0 commit comments

Comments
 (0)