Skip to content

Commit 93979b0

Browse files
committed
file download no longer adds a trailing newline when the output path is not specified
1 parent 9cd32bb commit 93979b0

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src/recodex_cli/call_command/command_state.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@ class CommandState:
1111
# whether the output should be minimized (single-line json, minimized YAML)
1212
output_minimized: bool = False
1313

14+
# when printing the output, should an extra newline be printed
15+
output_extra_newline: bool = True
16+
1417
def __init__(self, verbose: bool = False):
1518
self.verbose = verbose

src/recodex_cli/call_command/response_printer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ def print_response(response: ClientResponse, state: CommandState):
2626

2727
# print to console or file
2828
if state.output_path is None:
29-
print(out_string)
29+
if state.output_extra_newline:
30+
print(out_string)
31+
else:
32+
print(out_string, end="")
3033
else:
3134
with open(state.output_path, "w") as handle:
3235
handle.write(out_string)

src/recodex_cli/plugins/file_plugins.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ def download(
5555
state.output_path = out_path
5656
state.output_format = "raw"
5757

58+
# preserve the file content and do not add any extra newline
59+
state.output_extra_newline = False
60+
5861
def command():
5962
call(client, DefaultApi.uploaded_files_presenter_action_download, path_values=[id], state=state)
6063
cmd_utils.execute_with_verbosity(command, verbose)

0 commit comments

Comments
 (0)