diff --git a/.version b/.version index 07925e7..21fb4db 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -VERSION=1.3 \ No newline at end of file +VERSION=1.4 \ No newline at end of file diff --git a/README.md b/README.md index 21714c6..aaff219 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ scripts: # Installation On linux, just run: ```console -sudo curl -s -L https://github.com/SharpSet/sharpdev/releases/download/1.3/install.sh | sudo bash +sudo curl -s -L https://github.com/SharpSet/sharpdev/releases/download/1.4/install.sh | sudo bash ``` ## Command Options diff --git a/sharpdev.yml b/sharpdev.yml index c9574b0..62ecc82 100644 --- a/sharpdev.yml +++ b/sharpdev.yml @@ -1,23 +1,34 @@ version: 1.0 envfile: .env values: - TEST: Hello World! + TEST: Values work scripts: build: go build -o ./internal/sharpdev ./src test1: sharpdev build && ./internal/sharpdev echo1 - test2: sharpdev build && ./internal/sharpdev echo2 $_ARG1 + test2: sharpdev build && ./internal/sharpdev echo2 $_ARG1 $_ARG2 + test3: | sharpdev build cd ./internal - ./sharpdev -p echo1 + ./sharpdev -p echo3 + cd .. + + test4: | + sharpdev build + cd ./internal + ./sharpdev -v + ./sharpdev --version + cd .. echo1: echo TEST - echo2: echo $_ARG1 + echo2: echo $_ARG1 $_ARG2 + echo3: echo $ECHO full: | sharpdev test1 - sharpdev test2 Test2 + sharpdev test2 Args Works sharpdev test3 + sharpdev test4 diff --git a/src/files.go b/src/files.go index 9984192..d5dd6dd 100644 --- a/src/files.go +++ b/src/files.go @@ -90,7 +90,9 @@ func loadFile(parent *bool) config { return config{} } - devFile.EnvFile = dir + "/" + devFile.EnvFile + if devFile.EnvFile != "" { + devFile.EnvFile = dir + "/" + devFile.EnvFile + } return devFile } diff --git a/src/main.go b/src/main.go index 4098b86..bf1de82 100644 --- a/src/main.go +++ b/src/main.go @@ -15,18 +15,32 @@ import ( // add a -p flag var as bool var parent = flag.Bool("p", false, "Use a parent sharpdev.yml file") +var version = flag.Bool("v", false, "Get the version number") +var version2 = flag.Bool("version", false, "Get the version number") func main() { var name string flag.Parse() + // If -v is used, print version + if *version || *version2 { + fmt.Println(Version) + os.Exit(0) + } + // Load sharpdev file devFile := loadFile(parent) if devFile.Version == 0 { os.Exit(1) } + // Check if a envfile is required + if devFile.EnvFile != "" { + err := godotenv.Load(devFile.EnvFile) + check(err, "Failed to load env file2") + } + // Make Helper Function and Parse Flags setHelperFunction(devFile) @@ -93,12 +107,6 @@ func runScript(name string, devFile config) error { var commandStr string var ok bool - // Check if a envfile is required - if devFile.EnvFile != "" { - err := godotenv.Load(devFile.EnvFile) - check(err, "Failed to load env file") - } - // Check that the arg is actually a script if commandStr, ok = devFile.Scripts[name]; !ok { err := errors.New("key not in scripts config") diff --git a/src/structs.go b/src/structs.go index 2960c3b..3b8c2e3 100644 --- a/src/structs.go +++ b/src/structs.go @@ -6,3 +6,6 @@ type config struct { Scripts map[string]string `yml:"scripts"` Values map[string]string `yml:"values"` } + +// Version Number +var Version float32 = 1.4