Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #167 from commitdev/add-create-command
Add create command
- Loading branch information
Showing
14 changed files
with
163 additions
and
249 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"path" | ||
"strings" | ||
|
||
"github.com/commitdev/zero/internal/config/projectconfig" | ||
"github.com/commitdev/zero/internal/constants" | ||
"github.com/commitdev/zero/internal/generate" | ||
"github.com/commitdev/zero/pkg/util/exit" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var createConfigPath string | ||
|
||
func init() { | ||
createCmd.PersistentFlags().StringVarP(&createConfigPath, "config", "c", constants.ZeroProjectYml, "config path") | ||
|
||
rootCmd.AddCommand(createCmd) | ||
} | ||
|
||
var createCmd = &cobra.Command{ | ||
Use: "create", | ||
Short: fmt.Sprintf("Create projects for modules and configuration specified in %s", constants.ZeroProjectYml), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
Create(projectconfig.RootDir, createConfigPath) | ||
}, | ||
} | ||
|
||
func Create(dir string, createConfigPath string) { | ||
if strings.Trim(createConfigPath, " ") == "" { | ||
exit.Fatal("config path cannot be empty!") | ||
} | ||
configFilePath := path.Join(dir, createConfigPath) | ||
projectConfig := projectconfig.LoadConfig(configFilePath) | ||
|
||
generate.Generate(*projectConfig) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.