Skip to content

Commit

Permalink
chore: update YAML extension to .yaml
Browse files Browse the repository at this point in the history
Be in line with recommendations.
  • Loading branch information
ffenix113 committed Apr 17, 2024
1 parent 2cb86f4 commit 44e828b
Showing 3 changed files with 25 additions and 2 deletions.
25 changes: 24 additions & 1 deletion cmd/zigbee/firmware/build.go
Original file line number Diff line number Diff line change
@@ -4,6 +4,8 @@ import (
"context"
"errors"
"fmt"
"log"
"os"
"path/filepath"

"github.com/ffenix113/zigbee_home/config"
@@ -12,6 +14,8 @@ import (
"github.com/urfave/cli/v2"
)

const filenameArg = "config"

func buildCmd() *cli.Command {
return &cli.Command{
Name: "build",
@@ -61,7 +65,7 @@ func buildFirmware(ctx *cli.Context) error {
}

func parseConfig(ctx *cli.Context) (*config.Device, error) {
configPath := ctx.String("config")
configPath := getConfigName(ctx)
if configPath == "" {
return nil, errors.New("config path cannot be empty (it is set by default)")
}
@@ -74,6 +78,25 @@ func parseConfig(ctx *cli.Context) (*config.Device, error) {
return conf, nil
}

func getConfigName(ctx *cli.Context) string {
if ctx.IsSet(filenameArg) {
return ctx.String(filenameArg)
}

preferences := []string{"zigbee.yaml", "zigbee.yml"}
for _, preference := range preferences {
if _, err := os.Stat(preference); err == nil {
if preference == "zigbee.yml" {
log.Println("Default config file name changed to 'zigbee.yaml', please change name of your configuration file.")
}

return preference
}
}
// If both files don't exist - return default value.
return "zigbee.yaml"
}

func runBuild(ctx context.Context, device *config.Device, workDir string) error {
build := runner.NewCmd(
"west",
2 changes: 1 addition & 1 deletion cmd/zigbee/main.go
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ func main() {
Flags: []cli.Flag{
&cli.StringFlag{
Name: "config",
Value: "zigbee.yml",
Value: "zigbee.yaml",
},
},
}
File renamed without changes.

0 comments on commit 44e828b

Please # to comment.