Skip to content

Commit

Permalink
move function closer to the only place where it is used
Browse files Browse the repository at this point in the history
  • Loading branch information
ianic committed Sep 29, 2021
1 parent 3756e58 commit 230e373
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 27 deletions.
12 changes: 12 additions & 0 deletions cli/cmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,18 @@ func initTest(cmd *cobra.Command, args []string) *testCmd {
}
}

func getProject() (*config.Project, string) {
path, err := config.FindProjectRoot(".")
if err != nil {
log.Fatal(err)
}
p, err := config.LoadProject(path)
if err != nil {
log.Error(err)
}
return p, path
}

func initWatch(cmd *cobra.Command, args []string) *watchCmd {
method := cmd.Flag("method").Value.String()
test, _ := cmd.Flags().GetBool("test")
Expand Down
27 changes: 0 additions & 27 deletions cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,14 @@ package cmd

import (
"github.com/mantil-io/mantil/cli/log"
"github.com/mantil-io/mantil/config"
"github.com/spf13/cobra"
)

//var version setup.Version

// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "mantil",
Short: "Makes serverless development with Go and AWS Lambda joyful",
// Uncomment the following line if your bare application
// has an action associated with it:
// Run: func(cmd *cobra.Command, args []string) { },
}

// // Execute adds all child commands to the root command and sets flags appropriately.
// // This is called by main.main(). It only needs to happen once to the rootCmd.
// func Execute(v setup.Version) {
// version = v
// rootCmd.Version = version.String()
// cobra.CheckErr(rootCmd.Execute())
// }

func Root() *cobra.Command {
return rootCmd
}
Expand All @@ -43,15 +28,3 @@ func init() {
}
})
}

func getProject() (*config.Project, string) {
path, err := config.FindProjectRoot(".")
if err != nil {
log.Fatal(err)
}
p, err := config.LoadProject(path)
if err != nil {
log.Error(err)
}
return p, path
}

0 comments on commit 230e373

Please sign in to comment.