Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions internal/cmd/flags.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
package cmd

import (
"os"
"path"

"github.com/openshift-knative/deviate/pkg/cli"
"github.com/openshift-knative/deviate/pkg/metadata"
"github.com/spf13/cobra"
)

func addFlags(root *cobra.Command, opts *cli.Options) {
fl := root.PersistentFlags()
wd, err := os.Getwd()
if err != nil {
panic(err)
}
config := path.Join(wd, ".deviate.yaml")
fl.StringVar(&opts.ConfigPath, "config", config,
fl.StringVar(&opts.ConfigPath, "config", ".deviate.yaml",
metadata.Name+" configuration file")
}
13 changes: 11 additions & 2 deletions internal/cmd/sync.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"os"
"path"

"github.com/openshift-knative/deviate/pkg/cli"
Expand Down Expand Up @@ -29,9 +30,17 @@ func (s sync) run(cmd *cobra.Command, args []string) error {

func (s sync) project(args []string) func() config.Project {
return func() config.Project {
configPath := s.ConfigPath
wd, err := os.Getwd()
if err != nil {
wd = "/"
}
if !path.IsAbs(configPath) {
configPath = path.Join(wd, configPath)
}
project := config.Project{
ConfigPath: s.ConfigPath,
Path: path.Dir(s.ConfigPath),
ConfigPath: configPath,
Path: wd,
}
if len(args) > 0 {
project.Path = args[0]
Expand Down
Loading