Skip to content

Commit 10b534e

Browse files
committed
Initial commit
0 parents  commit 10b534e

File tree

9 files changed

+109
-0
lines changed

9 files changed

+109
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
env_config.yaml

HELP.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Usage:
2+
3+
env:get
4+
Returns the current .env filename that will be loaded
5+
when ash starts up.
6+
7+
env:set `$env_filename`
8+
Sets the new `$env_filename` that will be loaded when
9+
ash starts up.

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 Brandon Romano
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Whitespace-only changes.

ash_config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name: env
2+
package: github.com/ash-shell/env
3+
default_alias: env
4+
callable_prefix: Env

callable.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
##################################################
4+
# Displays the HELP.txt file
5+
##################################################
6+
Env__callable_main(){
7+
Env__callable_help
8+
}
9+
10+
##################################################
11+
# Displays the HELP.txt file
12+
##################################################
13+
Env__callable_help(){
14+
more "$Ash__ACTIVE_MODULE_DIRECTORY/HELP.txt"
15+
}
16+
17+
##################################################
18+
# Sets the new env filename that will be loaded
19+
# when ash starts up.
20+
##################################################
21+
Env__callable_set(){
22+
Env__set_filename "$1"
23+
Logger__alert "Env File: $(Env__get_filename)"
24+
}
25+
26+
##################################################
27+
# Displays the current .env filename that will be
28+
# loaded when ash starts up.
29+
##################################################
30+
Env__callable_get(){
31+
Logger__alert "Env File: $(Env__get_filename)"
32+
}

lib/config_manager.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
##################################################
4+
# @returns: The current .env filename to load
5+
# when ash starts up
6+
##################################################
7+
Env__get_filename(){
8+
if [[ ! -f "$Env_CONFIG_FILE" ]]; then
9+
Env__set_filename ".env"
10+
fi
11+
eval $(YamlParse__parse "$Env_CONFIG_FILE" "Env_config_")
12+
echo "$Env_config_env_file"
13+
}
14+
15+
##################################################
16+
# Sets the filename of the env file to load
17+
#
18+
# @param $1: The filename of the .env file to load
19+
# when ash starts up
20+
##################################################
21+
Env__set_filename(){
22+
local filename="$1"
23+
if [[ "$filename" = "" ]]; then
24+
filename=".env"
25+
fi
26+
if [[ -f "$Env_CONFIG_FILE" ]]; then
27+
rm "$Env_CONFIG_FILE"
28+
fi
29+
echo "env_file: $filename" >> "$Env_CONFIG_FILE"
30+
}

lib/globals.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
Env_PACKAGE_LOCATION="$(Ash__find_module_directory "github.com/ash-shell/env")"
4+
Env_CONFIG_FILE="$Env_PACKAGE_LOCATION/env_config.yaml"

lib/loader.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
##################################################
4+
# Loads the current environment file
5+
##################################################
6+
Env__load(){
7+
source $(Env__get_filename)
8+
}

0 commit comments

Comments
 (0)