Skip to content

possible cargo-script-run #7

@nathanross

Description

@nathanross

Hashbang-callable and automatically suppresses cargo compile messages except on compile error. i.e. STDOUT (and stderr) of executing a successfully-compilable script is always just the product of the compiled script's execution.

This is so for bash, python, etc. scripts which other programs/scripts execute directly and use the stdout, a rust file+cargo-script can be used as a drop-in replacement.

#!/bin/sh
# cargo-script-run 

if ! results=`cargo script --build-only $1 2>&1`; then
    echo -e "$results"
    exit 1
fi
cargo script $@
exit 0

OTOH I can see the value of saying "if you're going to be using it as an executable called by other programs, make it into an actual rust project." So it's just an idea.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions