(p *ProjectOptions, dockerCli command.Cli, backendOptions *BackendOptions)
| 38 | } |
| 39 | |
| 40 | func vizCommand(p *ProjectOptions, dockerCli command.Cli, backendOptions *BackendOptions) *cobra.Command { |
| 41 | opts := vizOptions{ |
| 42 | ProjectOptions: p, |
| 43 | } |
| 44 | var indentationSize int |
| 45 | var useSpaces bool |
| 46 | |
| 47 | cmd := &cobra.Command{ |
| 48 | Use: "viz [OPTIONS]", |
| 49 | Short: "EXPERIMENTAL - Generate a graphviz graph from your compose file", |
| 50 | PreRunE: Adapt(func(ctx context.Context, args []string) error { |
| 51 | var err error |
| 52 | opts.indentationStr, err = preferredIndentationStr(indentationSize, useSpaces) |
| 53 | return err |
| 54 | }), |
| 55 | RunE: Adapt(func(ctx context.Context, args []string) error { |
| 56 | return runViz(ctx, dockerCli, backendOptions, &opts) |
| 57 | }), |
| 58 | } |
| 59 | |
| 60 | cmd.Flags().BoolVar(&opts.includePorts, "ports", false, "Include service's exposed ports in output graph") |
| 61 | cmd.Flags().BoolVar(&opts.includeNetworks, "networks", false, "Include service's attached networks in output graph") |
| 62 | cmd.Flags().BoolVar(&opts.includeImageName, "image", false, "Include service's image name in output graph") |
| 63 | cmd.Flags().IntVar(&indentationSize, "indentation-size", 1, "Number of tabs or spaces to use for indentation") |
| 64 | cmd.Flags().BoolVar(&useSpaces, "spaces", false, "If given, space character ' ' will be used to indent,\notherwise tab character '\\t' will be used") |
| 65 | return cmd |
| 66 | } |
| 67 | |
| 68 | func runViz(ctx context.Context, dockerCli command.Cli, backendOptions *BackendOptions, opts *vizOptions) error { |
| 69 | _, _ = fmt.Fprintln(os.Stderr, "viz command is EXPERIMENTAL") |
no test coverage detected