feat: rename env names

This commit is contained in:
2022-08-06 16:33:46 +08:00
parent 93de208e17
commit 439eb7d3c3
2 changed files with 6 additions and 6 deletions

View File

@@ -13,9 +13,9 @@ Environment variables
| Env Key | Env Value |
|---------------|----------------------------------------------------------------|
| `HOME` | User home, default by OS system |
| `SKIP_CACHE` | Skip compiled cached file , turn on `true`, `yes`, `on` or `1` |
| `RUST_SCRIPT` | `rust_script` command line bin file |
| `MAX_SCRIPT_LEN` | Max script length |
| `RUNRS_SKIP_CACHE` | Skip compiled cached file , turn on `true`, `yes`, `on` or `1` |
| `RUNRS_RUST_SCRIPT` | `rust_script` command line bin file |
| `RUNRS_MAX_SCRIPT_LEN` | Max script length |
<br>

View File

@@ -36,7 +36,7 @@ fn main() {
}
fn build_script_command(rust_script: PathBuf, script_file: &str, script_sha256: &str, cache_script_bin_name: &str) -> Command {
let skip_cache = is_env_on("SKIP_CACHE");
let skip_cache = is_env_on("RUNRS_SKIP_CACHE");
let cache_script_bin_name_exists = fs::metadata(&cache_script_bin_name).is_ok();
debugging!("Bin name: {} {}exists", cache_script_bin_name, iff!(cache_script_bin_name_exists, "", "not "));
if !skip_cache && cache_script_bin_name_exists {
@@ -98,7 +98,7 @@ runrs <script.rs> [arguments]
fn read_file_and_digest(script_file: &str) -> (String, String) {
let default_max_script_len = 1024 * 1024;
let max_script_len: u64 = env::var("MAX_SCRIPT_LEN")
let max_script_len: u64 = env::var("RUNRS_MAX_SCRIPT_LEN")
.map(|len| len.parse().unwrap_or_else(|| default_max_script_len)).unwrap_or_else(|| default_max_script_len);
match fs::metadata(script_file) {
Err(_) => failure_and_exit!("Script file not exists: {}", script_file),
@@ -117,7 +117,7 @@ fn read_file_and_digest(script_file: &str) -> (String, String) {
}
fn get_run_script_bin_name(home: &str) -> PathBuf {
if let Ok(rust_script) = env::var("RUST_SCRIPT") {
if let Ok(rust_script) = env::var("RUNRS_RUST_SCRIPT") {
let rust_script_path_buf = PathBuf::from(&rust_script);
if !rust_script_path_buf.exists() {
warning!("RUST_SCRIPT={} not exists", &rust_script);