Skip to content

Commit 4452fd1

Browse files
committed
change basic to dotenv
1 parent b907d70 commit 4452fd1

File tree

7 files changed

+36
-36
lines changed

7 files changed

+36
-36
lines changed

Readme.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ sicher init
3838

3939
**_Optional flags:_**
4040

41-
| flag | description | default | options |
42-
| ---------- | --------------------------------------------------------------------- | ------- | ------------- |
43-
| -env | set the environment name | dev | |
44-
| -path | set the path to the credentials file | . | |
45-
| -style | set the style of the decrypted credentials file | basic | basic or yaml |
46-
| -gitignore | path to the gitignore file. the key file will be added here, if given | | |
41+
| flag | description | default | options |
42+
| ---------- | --------------------------------------------------------------------- | ------- | -------------- |
43+
| -env | set the environment name | dev | |
44+
| -path | set the path to the credentials file | . | |
45+
| -style | set the style of the decrypted credentials file | dotenv | dotenv or yaml |
46+
| -gitignore | path to the gitignore file. the key file will be added here, if given | | |
4747

4848
This will create a key file `{environment}.key` and an encrypted credentials file `{environment}.enc` in the current directory. The environment name is optional and defaults to `dev`, but can be set to anything else with the `-env` flag.
4949

@@ -55,12 +55,12 @@ sicher edit
5555

5656
**_Optional flags:_**
5757

58-
| flag | description | default | options |
59-
| ------- | ----------------------------------------------- | ------- | ------------- |
60-
| -env | set the environment name | dev | |
61-
| -path | set the path to the credentials file | . | |
62-
| -editor | set the editor to use | vim | vim, nano, vi |
63-
| -style | set the style of the decrypted credentials file | basic | basic or yaml |
58+
| flag | description | default | options |
59+
| ------- | ----------------------------------------------- | ------- | -------------- |
60+
| -env | set the environment name | dev | |
61+
| -path | set the path to the credentials file | . | |
62+
| -editor | set the editor to use | vim | vim, nano, vi |
63+
| -style | set the style of the decrypted credentials file | dotenv | dotenv or yaml |
6464

6565
This will create a temporary file, decrypt the credentials into it, and open it in your editor. The editor defaults to `vim`, but can be also set to `nano` or `vi` with the `-editor` flag. The temporary file is destroyed after each save, and the encrypted credentials file is updated with the new content.
6666

@@ -85,7 +85,7 @@ func main() {
8585
var config Config
8686

8787
s := sicher.New("dev", ".")
88-
s.SetEnvStyle("yaml") // default is basic
88+
s.SetEnvStyle("yaml") // default is dotenv
8989
err := s.LoadEnv("", &cfg)
9090
if err != nil {
9191
fmt.Println(err)
@@ -105,7 +105,7 @@ The `LoadEnv` function will load the credentials from the encrypted file `{envir
105105

106106
All env files should be in the format like the example below:
107107

108-
For `basic envType`:
108+
For `dotenv`:
109109

110110
```
111111
PORT=8080
@@ -114,7 +114,7 @@ MONGO_DB_NAME=sicher
114114
APP_URL=http://localhost:8080
115115
```
116116

117-
For `Yaml envType`:
117+
For `yaml`:
118118

119119
```
120120
PORT:8080

cli/sicher.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ sicher edit
3131
func init() {
3232
flag.StringVar(&pathFlag, "path", ".", "Path to the project")
3333
flag.StringVar(&envFlag, "env", "dev", "Environment to use")
34-
flag.StringVar(&styleFlag, "style", string(sicher.DefaultEnvStyle), "Env file style. Valid values are basic and yaml")
34+
flag.StringVar(&styleFlag, "style", string(sicher.DefaultEnvStyle), "Env file style. Valid values are dotenv and yaml")
3535
flag.StringVar(&editorFlag, "editor", "vim", "Select editor. vim | vi | nano")
3636
flag.StringVar(&gitignorePathFlag, "gitignore", ".", "Path to the gitignore file")
3737

example/sample.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func LoadConfigMap() {
3333
cfg := make(map[string]string)
3434

3535
s := sicher.New("dev", ".")
36-
s.SetEnvStyle("yaml") // default is basic
36+
s.SetEnvStyle("yaml") // default is dotenv
3737
err := s.LoadEnv("", &cfg)
3838
if err != nil {
3939
fmt.Println(err)

helpers.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@ import (
1717
type EnvStyle string
1818

1919
const (
20-
YAML EnvStyle = "yaml"
21-
YML EnvStyle = "yml"
22-
BASIC EnvStyle = "basic"
20+
YAML EnvStyle = "yaml"
21+
YML EnvStyle = "yml"
22+
DOTENV EnvStyle = "dotenv"
2323
)
2424

2525
var envStyleDelim = map[EnvStyle]string{
26-
YAML: ":",
27-
YML: ":",
28-
BASIC: "=",
26+
YAML: ":",
27+
YML: ":",
28+
DOTENV: "=",
2929
}
3030

3131
var envStyleExt = map[EnvStyle]string{
32-
YAML: "yml",
33-
YML: "yml",
34-
BASIC: "env",
32+
YAML: "yml",
33+
YML: "yml",
34+
DOTENV: "env",
3535
}
3636

3737
// cleanUpFile removes the given file
@@ -75,7 +75,7 @@ func generateKey() string {
7575
// parseConfig parses the environment variables into a map
7676
func parseConfig(config []byte, store map[string]string, envType EnvStyle) (err error) {
7777

78-
if envType != BASIC && envType != YAML && envType != YML {
78+
if envType != DOTENV && envType != YAML && envType != YML {
7979
return errors.New("invalid environment type")
8080
}
8181

helpers_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ PORT=8080
4545
URI=localhost
4646
#OLD_PORT=5000
4747
`)
48-
err := parseConfig(cfg, enMap, "basic")
48+
err := parseConfig(cfg, enMap, "dotenv")
4949
if err != nil {
5050
t.Errorf("Unable to parse config; %v", err)
5151
}
@@ -67,7 +67,7 @@ URI=localhost
6767

6868
parseConfig(cfg, enMap, "yaml")
6969
if len(enMap) != 0 {
70-
t.Errorf("Expected basic style env not be be parseable with yaml envType")
70+
t.Errorf("Expected dotenv style env not be be parseable with yaml envType")
7171
}
7272
}
7373
func TestYamlParseConfig(t *testing.T) {

sicher.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020

2121
var delimiter = "==--=="
2222
var defaultEnv = "dev"
23-
var DefaultEnvStyle = BASIC
23+
var DefaultEnvStyle = DOTENV
2424
var (
2525
execCmd = exec.Command
2626
stdIn io.ReadWriter = os.Stdin
@@ -55,7 +55,7 @@ func New(environment string, path string) *sicher {
5555
path = "."
5656
}
5757
path, _ = filepath.Abs(path)
58-
return &sicher{Path: path + "/", Environment: environment, data: make(map[string]string), envStyle: BASIC}
58+
return &sicher{Path: path + "/", Environment: environment, data: make(map[string]string), envStyle: DOTENV}
5959
}
6060

6161
// Initialize initializes the sicher project and creates the necessary files
@@ -291,8 +291,8 @@ func (s *sicher) LoadEnv(prefix string, configFile interface{}) error {
291291
}
292292

293293
func (s *sicher) SetEnvStyle(style string) {
294-
if style != "basic" && style != "yaml" && style != "yml" {
295-
fmt.Println("Invalid style: Select one of basic, yml, or yaml")
294+
if style != "dotenv" && style != "yaml" && style != "yml" {
295+
fmt.Println("Invalid style: Select one of dotenv, yml, or yaml")
296296
os.Exit(1)
297297
}
298298
s.envStyle = EnvStyle(style)

sicher_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ func TestNewWithEnvironment(t *testing.T) {
4040
}
4141
func TestEnvStyle(t *testing.T) {
4242
s := New("testenv", "")
43-
s.SetEnvStyle("basic")
43+
s.SetEnvStyle("dotenv")
4444

45-
if s.envStyle != "basic" {
46-
t.Errorf("Expected environment style to be set to %s, got %s", "basic", s.envStyle)
45+
if s.envStyle != "dotenv" {
46+
t.Errorf("Expected environment style to be set to %s, got %s", "dotenv", s.envStyle)
4747
}
4848

4949
}

0 commit comments

Comments
 (0)