Skip to content

Commit

Permalink
Added a bunch of nice to haves.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sharpz7 committed Jun 23, 2022
1 parent d52fac9 commit ee7da8d
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION=1.3
VERSION=1.4
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 16 additions & 5 deletions sharpdev.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion src/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
20 changes: 14 additions & 6 deletions src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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")
Expand Down
3 changes: 3 additions & 0 deletions src/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit ee7da8d

Please sign in to comment.