Skip to content

Commit

Permalink
feat: add --version
Browse files Browse the repository at this point in the history
  • Loading branch information
brodo committed Sep 30, 2022
1 parent 0f9730b commit 91ad76b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "json_env"
version = "1.0.7"
version = "1.1.0"
edition = "2021"
license = "Apache-2.0"
description ="`json_env` loads an environment variables from a file called `.env.json` in the current directory and starts a subprocess with them."
Expand Down
13 changes: 11 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,31 @@ use std::fs::File;
use std::io::Read;
use std::process::Command;


const VERSION: &str = env!("CARGO_PKG_VERSION");

// `json_env` is [dotenv](https://github.com/motdotla/dotenv), but with JSON.
// See [readme](Readme.md) for more information.
fn main() {
let args: Vec<String> = env::args().collect();
let help_text = concat!("json_env reads the .env.json file in the current directory and runs a program with these environment variables.\n",
"Usage:",
"json_env <executable> <options for executable>\n",
"json_env itself has no config options"
"json_env itself has no config options."
);

if args.len() < 2 {
println!("{}", help_text);
}

if args[1] == "--help" {
println!("{}", help_text)
println!("{}", help_text);
return;
}

if args[1] == "--version" {
println!("json_env version {}", VERSION);
return;
}

match File::open(".env.json") {
Expand Down

0 comments on commit 91ad76b

Please sign in to comment.