Permalink
Browse files

add dir to protoeasy.yml

  • Loading branch information...
peter-edge committed Dec 22, 2015
1 parent 100a9f5 commit 4bf3a34dcfa142528075b9a7d3e4da358e5eca37
Showing with 33 additions and 9 deletions.
  1. +1 −1 Makefile
  2. +20 −8 cmd/protoeasy/main.go
  3. +1 −0 example/complete/protoeasy.yml → protoeasy-example-complete.yaml
  4. +1 −0 protoeasy.go
  5. +10 −0 protoeasy.yaml
@@ -87,7 +87,7 @@ example-complete:
example-complete-file:
rm -rf _example-out/complete
protoeasy --out=_example-out/complete example/complete
protoeasy --out=_example-out/complete -f protoeasy-example-complete.yaml
go build ./_example-out/complete/go/...
example-proto2:
@@ -43,17 +43,13 @@ func do(appEnvObj interface{}) error {
rootCmd := &cobra.Command{
Use: fmt.Sprintf("%s directory", os.Args[0]),
Run: pkgcobra.RunFixedArgs(1, func(args []string) error {
if err := pkgcobra.CheckFixedArgs(1, args); err != nil {
return err
}
Run: pkgcobra.RunBoundedArgs(pkgcobra.Bounds{Max: 1}, func(args []string) error {
if err := optionsToCompileOptions(options, compileOptions); err != nil {
return err
}
dirPath := args[0]
outDirPath := dirPath
if options.OutDirPath != "" {
outDirPath = options.OutDirPath
dirPath := ""
if len(args) > 0 {
dirPath = args[0]
}
if !options.NoFileCompileOptions {
fileCompileOptionsPath := filepath.Join(dirPath, options.FileCompileOptionsPath)
@@ -68,12 +64,28 @@ func do(appEnvObj interface{}) error {
if err != nil {
return err
}
// instead of doing a foundFileCompileOptionsFile bool
if dirPath == "" {
dirPath = "."
}
if fileCompileOptions.Dir != "" {
dirPath = filepath.Join(dirPath, fileCompileOptions.Dir)
}
compileOptions, err = fileCompileOptions.ToCompileOptions()
if err != nil {
return err
}
}
}
if dirPath == "" {
return fmt.Errorf("Directory path to base protoeasy compile must either be the first argument if no protoeasy options file found (usually %s)", protoeasy.DefaultFileCompileOptionsFile)
}
protolog.Infof("Using input directory %s", dirPath)
outDirPath := dirPath
if options.OutDirPath != "" {
outDirPath = options.OutDirPath
}
protolog.Infof("Using output directory %s", outDirPath)
data, err := json.Marshal(compileOptions)
if err != nil {
return err
@@ -1,4 +1,5 @@
version: v1
dir: example/complete
plugins:
- grpc
- grpc_gateway
@@ -50,6 +50,7 @@ var (
// FileCompileOptions are CompileOptions with JSON and YAML tags ready to be read from a file.
type FileCompileOptions struct {
Version string `json:"version,omitempty" yaml:"version,omitempty"`
Dir string `json:"dir,omitempty" yaml:"dir,omitempty"`
Plugins []string `json:"plugins,omitempty" yaml:"plugins,omitempty"`
Options struct {
NoDefaultIncludes bool `json:"no_default_includes,omitempty" yaml:"no_default_includes,omitempty"`
@@ -0,0 +1,10 @@
version: v1
plugins:
- go
- grpc
options:
go:
import_path: go.pedge.io/protoeasy
exclude:
- vendor
- example

0 comments on commit 4bf3a34

Please sign in to comment.