You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`--gen-pkg-only`: Generate the Cargo package, but don't compile or run it. Effectively "unpacks" the script into a Cargo package.
106
102
-`--test`: Compile and run tests.
107
103
108
-
<aname="shebang"></a>
109
-
### Executable Scripts
104
+
## Executable Scripts
110
105
111
106
On Unix systems, you can use `#!/usr/bin/env rust-script` as a shebang line in a Rust script. This will allow you to execute a script file directly.
112
107
@@ -118,8 +113,7 @@ Uninstall the file association with `rust-script --uninstall-file-association`.
118
113
119
114
If you want to make a script usable across platforms, use *both* a hashbang line *and* give the file a `.crs` file extension.
120
115
121
-
<aname="expressions"></a>
122
-
### Expressions
116
+
## Expressions
123
117
124
118
`rust-script` can also run pieces of Rust code directly from the command line. This is done by providing the `--expr` option; this causes `rust-script` to interpret the `<script>` argument as source code *instead* of as a file path. For example, code can be executed from the command line in a number of ways:
Note that, like with expressions, you can specify a custom template for stream filters.
170
163
171
-
<a name="env-vars"></a>
172
-
### Environment Variables
164
+
## Environment Variables
173
165
174
166
The following environment variables are provided to scripts by `rust-script`:
175
167
@@ -181,8 +173,7 @@ The following environment variables are provided to scripts by `rust-script`:
181
173
182
174
- `CARGO_SCRIPT_SCRIPT_PATH`: absolute path to the script being run, assuming one exists. Set to the empty string for expressions.
183
175
184
-
<a name="templates"></a>
185
-
### Templates
176
+
## Templates
186
177
187
178
You can use templates to avoid having to re-specify common code and dependencies. You can view a list of your templates by running `rust-script templates list` (note the hyphen), or show the folder in which they should be stored by running `rust-script templates show`. You can dump the contents of a template using `rust-script templates dump NAME`.
In addition, there are three built-in templates: `expr`, `loop`, and `loop-count`. These are used for the `--expr`, `--loop`, and `--loop --count` invocation forms. They can be overridden by placing templates with the same name in the template folder. If you have *not* overridden them, you can dump the contents of these built-in templates using the `templates dump` command noted above.
218
209
219
-
<a name="troubleshooting"></a>
220
-
### Troubleshooting
210
+
## Troubleshooting
221
211
222
212
Please report all issues on [the GitHub issue tracker](https://github.com/fornwall/rust-script/issues).
0 commit comments