CanRunWithoutDocker returns true if the command or flag can run without Docker.
()
| 121 | |
| 122 | // CanRunWithoutDocker returns true if the command or flag can run without Docker. |
| 123 | func CanRunWithoutDocker() bool { |
| 124 | if len(os.Args) < 2 { |
| 125 | return true |
| 126 | } |
| 127 | // Some commands don't support Cobra help, because they are wrappers |
| 128 | if slices.Contains([]string{"composer"}, os.Args[1]) { |
| 129 | return false |
| 130 | } |
| 131 | if output.ParseBoolFlag("version", "v") || output.ParseBoolFlag("help", "h") { |
| 132 | return true |
| 133 | } |
| 134 | if len(os.Args) == 2 && output.ParseBoolFlag("json-output", "j") { |
| 135 | return true |
| 136 | } |
| 137 | // help and hostname should not require docker |
| 138 | if slices.Contains([]string{"help", "hostname"}, os.Args[1]) { |
| 139 | return true |
| 140 | } |
| 141 | return false |
| 142 | } |
| 143 | |
| 144 | // CheckAvailableSpace outputs a warning if Docker space is low |
| 145 | func CheckAvailableSpace() { |