allyes.go 636 B

12345678910111213141516171819202122232425262728
  1. // Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved.
  2. //
  3. // This Source Code Form is subject to the terms of the MIT License.
  4. // If a copy of the MIT was not distributed with this file,
  5. // You can obtain one at https://github.com/gogf/gf.
  6. package allyes
  7. import (
  8. "github.com/gogf/gf/v2/os/gcmd"
  9. "github.com/gogf/gf/v2/os/genv"
  10. )
  11. const (
  12. EnvName = "GF_CLI_ALL_YES"
  13. )
  14. // Init initializes the package manually.
  15. func Init() {
  16. if gcmd.GetOpt("y") != nil {
  17. genv.MustSet(EnvName, "1")
  18. }
  19. }
  20. // Check checks whether option allow all yes for command.
  21. func Check() bool {
  22. return genv.Get(EnvName).String() == "1"
  23. }