Command returns a cobra.Command for use with (*cobra.Command).AddCommand.
()
| 2588 | |
| 2589 | // Command returns a cobra.Command for use with (*cobra.Command).AddCommand. |
| 2590 | func (c *cmdStorageVolumeNBD) Command() *cobra.Command { |
| 2591 | cmd := &cobra.Command{} |
| 2592 | cmd.Use = cli.U("nbd", cmdStorageVolumeNBDUsage...) |
| 2593 | cmd.Short = i18n.G("NBD access to a block storage volume") |
| 2594 | cmd.Long = cli.FormatSection(color.DescriptionPrefix, i18n.G( |
| 2595 | `NBD access to a block storage volume`, |
| 2596 | )) |
| 2597 | |
| 2598 | cli.AddStringFlag(cmd.Flags(), &c.flagAddress, "address", "", "", i18n.G("Specific address to listen on")) |
| 2599 | cli.AddBoolFlag(cmd.Flags(), &c.flagWritable, "writable", i18n.G("Get write access to the disk")) |
| 2600 | |
| 2601 | cmd.RunE = c.Run |
| 2602 | |
| 2603 | // completion for pool, volume, host path |
| 2604 | cmd.ValidArgsFunction = func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { |
| 2605 | if len(args) == 0 { |
| 2606 | return c.global.cmpStoragePools(toComplete) |
| 2607 | } |
| 2608 | |
| 2609 | if len(args) == 1 { |
| 2610 | return c.global.cmpStoragePoolVolumes(args[0]) |
| 2611 | } |
| 2612 | |
| 2613 | return nil, cobra.ShellCompDirectiveNoFileComp |
| 2614 | } |
| 2615 | |
| 2616 | return cmd |
| 2617 | } |
| 2618 | |
| 2619 | // Run runs the actual command logic. |
| 2620 | func (c *cmdStorageVolumeNBD) Run(cmd *cobra.Command, args []string) error { |
no test coverage detected