()
| 30 | ) |
| 31 | |
| 32 | func LogsCommand() *cobra.Command { |
| 33 | const shortUsage = "Fetch the logs of a container. Expected to be used with 'nerdctl run -d'." |
| 34 | const longUsage = `Fetch the logs of a container. |
| 35 | |
| 36 | The following containers are supported: |
| 37 | - Containers created with 'nerdctl run -d'. The log is currently empty for containers created without '-d'. |
| 38 | - Containers created with 'nerdctl compose'. |
| 39 | - Containers created with Kubernetes (EXPERIMENTAL). |
| 40 | ` |
| 41 | var cmd = &cobra.Command{ |
| 42 | Use: "logs [flags] CONTAINER", |
| 43 | Args: helpers.IsExactArgs(1), |
| 44 | Short: shortUsage, |
| 45 | Long: longUsage, |
| 46 | RunE: logsAction, |
| 47 | ValidArgsFunction: logsShellComplete, |
| 48 | SilenceUsage: true, |
| 49 | SilenceErrors: true, |
| 50 | } |
| 51 | cmd.Flags().BoolP("follow", "f", false, "Follow log output") |
| 52 | cmd.Flags().BoolP("timestamps", "t", false, "Show timestamps") |
| 53 | cmd.Flags().StringP("tail", "n", "all", "Number of lines to show from the end of the logs") |
| 54 | cmd.Flags().String("since", "", "Show logs since timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)") |
| 55 | cmd.Flags().String("until", "", "Show logs before a timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)") |
| 56 | cmd.Flags().Bool("details", false, "Show extra details provided to logs") |
| 57 | return cmd |
| 58 | } |
| 59 | |
| 60 | func logsOptions(cmd *cobra.Command) (types.ContainerLogsOptions, error) { |
| 61 | globalOptions, err := helpers.ProcessRootCmdFlags(cmd) |
no test coverage detected
searching dependent graphs…