You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.5 KiB

  1. /*
  2. Copyright © 2020 NAME HERE <EMAIL ADDRESS>
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package gva
  14. import (
  15. "gin-vue-admin/utils"
  16. "github.com/spf13/cobra"
  17. "os"
  18. )
  19. // runCmd represents the run command
  20. var runCmd = &cobra.Command{
  21. Use: "run",
  22. Short: "running go codes with hot-compiled-like feature",
  23. Long: `
  24. The "run" command is used for running go codes with hot-compiled-like feature,
  25. which compiles and runs the go codes asynchronously when codes change.
  26. `,
  27. Run: func(cmd *cobra.Command, args []string) {
  28. w := utils.NewWatch()
  29. t := utils.NewT()
  30. path, _ := os.Getwd()
  31. go w.Watch(path, t)
  32. t.RunTask()
  33. },
  34. }
  35. func init() {
  36. rootCmd.AddCommand(runCmd)
  37. // Here you will define your flags and configuration settings.
  38. // Cobra supports Persistent Flags which will work for this command
  39. // and all subcommands, e.g.:
  40. // runCmd.PersistentFlags().String("foo", "", "A help for foo")
  41. // Cobra supports local flags which will only run when this command
  42. // is called directly, e.g.:
  43. // runCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
  44. }