()
| 41 | } |
| 42 | |
| 43 | func init() { |
| 44 | DdevLogsCmd.Flags().BoolVarP(&follow, "follow", "f", false, "Follow the logs in real time.") |
| 45 | DdevLogsCmd.Flags().BoolVarP(×tamp, "time", "t", false, "Add timestamps to logs") |
| 46 | DdevLogsCmd.Flags().StringVarP(&serviceType, "service", "s", "web", "Defines the service to retrieve logs from. [e.g. web, db]") |
| 47 | _ = DdevLogsCmd.RegisterFlagCompletionFunc("service", ddevapp.GetServiceNamesFunc(true)) |
| 48 | DdevLogsCmd.Flags().StringVarP(&tail, "tail", "", "", "How many lines to show") |
| 49 | |
| 50 | // JSON formatted output isn't supported, so we should hide the global --json-output flag |
| 51 | // We have to do that within the help function, since the global flag hasn't been added yet during init() |
| 52 | originalHelpFunc := DdevLogsCmd.HelpFunc() |
| 53 | DdevLogsCmd.SetHelpFunc(func(command *cobra.Command, strings []string) { |
| 54 | _ = command.Flags().MarkHidden("json-output") |
| 55 | originalHelpFunc(command, strings) |
| 56 | }) |
| 57 | // We need to do the same with the flag error function in case flags can't be parsed correctly, |
| 58 | // because that output (although identical to the help function) is generated separately. |
| 59 | originalErrorFunc := DdevLogsCmd.FlagErrorFunc() |
| 60 | DdevLogsCmd.SetFlagErrorFunc(func(command *cobra.Command, err error) error { |
| 61 | _ = command.Flags().MarkHidden("json-output") |
| 62 | return originalErrorFunc(command, err) |
| 63 | }) |
| 64 | |
| 65 | RootCmd.AddCommand(DdevLogsCmd) |
| 66 | } |
nothing calls this directly
no test coverage detected