Skip to content

Add post_upload_script - #22

Draft
djcrabhat wants to merge 6 commits into
zig-for:mainfrom
djcrabhat:main
Draft

Add post_upload_script #22
djcrabhat wants to merge 6 commits into
zig-for:mainfrom
djcrabhat:main

Conversation

@djcrabhat

Copy link
Copy Markdown

Add a post_upload_script to execute a shell command after a successful file upload.

Had the idea when I wanted to automate my stream overlay, I use send_file.exe to map to my MSUs. The example shows writing to a .txt file the name of the matched definition.

djcrabhat and others added 6 commits August 28, 2026 14:35
Adds an optional post_upload_script to the config, that when provided, executes a command, with {} replacement values.
3c7c8e7 was committed mid-edit and left send_file.cpp with character
literals that don't compile ('' and a raw newline for '\r'/'\n', and
''' for '\''). Restore them so the shell escaping works as intended:
single quotes on unix, carets with quotes dropped for cmd.exe. The
rest of the review fixes (escaping the substituted values, decoding
std::system's POSIX wait status, the destination picker's off-by-one)
went in with that commit already.

Also:
- Document that placeholders should be left unquoted since values are
  escaped, and put the redirect first in the Windows example so a
  destination name ending in a digit isn't parsed by cmd.exe as a
  stream number.
- Drop the unused protobuf::libprotoc link; only libprotobuf is needed
  for the generated pb.cc.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The tooling that applied the previous fixes rewrote the file with LF,
which churned all 252 lines against the CRLF the rest of the repo (and
this file's own history) uses. Content is unchanged from e13e0b6.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The post-upload script code had accumulated in send_file.cpp, which is
otherwise just the program's flow, and ExpandTemplate sat in config.cpp
even though the only thing that expands templates is the script runner.
Collect all three in one place:

- New shell.h / shell.cpp holding ExpandTemplate, EscapeForShell and
  RunPostUploadScript, moved as-is.
- send_file.cpp is back to do_error and main, with its include list
  restored to what it was before the feature plus shell.h.
- config.h / config.cpp keep only the post_upload_script field and its
  parsing, dropping the <utility> and <algorithm> includes that were
  there for ExpandTemplate.
- Name the script runner RunPostUploadScript to match the other two.

No behaviour change.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
It came back in 96fb337 by accident - the file was staged wholesale
rather than re-diffed - and CMake's generate step fails on it because
the target isn'\''t exported. Nothing here uses protoc's compiler APIs,
only the generated pb.cc, which needs libprotobuf alone.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Reverts 3043616 and the same change in e13e0b6. The removal was a local
workaround that was sitting uncommitted in the working tree when the
review ran, and I should not have folded it into a commit. Whether this
link stays is the maintainer call, so main goes back to what it was.

Note that a fresh configure fails on this target with a current vcpkg;
CI pins vcpkg at 5bf0c55, where it still exists.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant