Skip to content

Commit

Permalink
feat: implement command builder interface
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyasbhat0 committed Nov 30, 2023
1 parent 49705f5 commit cd7b56c
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 8 deletions.
82 changes: 82 additions & 0 deletions cli/common/command_builder.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package common

import "github.com/spf13/cobra"

type diveCommandBuilder struct {
cmd *cobra.Command
}

func NewDiveCommandBuilder() *diveCommandBuilder {
return &diveCommandBuilder{
cmd: &cobra.Command{},
}
}

// AddCommand adds a subcommand to the command.
func (d *diveCommandBuilder) AddCommand(cmd *cobra.Command) CommandBuilder {
panic("not implemented") // TODO: Implement
}

// Add Persistent Bool Flag
func (d *diveCommandBuilder) AddBoolPersistentFlag(p *bool, name string, value bool, usage string) CommandBuilder {
panic("not implemented") // TODO: Implement
}

// Add Persistent Bool Flag with Short hand
func (d *diveCommandBuilder) AddBoolPersistentFlagWithShortHand(p *bool, name string, value bool, usage string, shorthand string) CommandBuilder {
panic("not implemented") // TODO: Implement
}

// Add Persistent String Flag
func (d *diveCommandBuilder) AddStringPersistentFlag(p *string, name string, value string, usage string) CommandBuilder {
panic("not implemented") // TODO: Implement
}

// Add Persistent String Flag with Short hand
func (d *diveCommandBuilder) AddStringPersistentFlagWithShortHand(p *string, name string, shorthand string, value string, usage string) CommandBuilder {
panic("not implemented") // TODO: Implement
}

// Add StringFlag adds a string flag to the command that persists
func (d *diveCommandBuilder) AddStringFlag(name string, value string, usage string) CommandBuilder {
panic("not implemented") // TODO: Implement
}

// Add StringFlag adds a string flag to the command that persists with short hand
func (d *diveCommandBuilder) AddStringFlagWithShortHand(p *string, name string, shorthand string, value string, usage string) CommandBuilder {
panic("not implemented") // TODO: Implement
}

// Add BooFlag adds a boolean flag to the command that persists
func (d *diveCommandBuilder) AddBoolFlag(name string, value bool, usage string) CommandBuilder {
panic("not implemented") // TODO: Implement
}

func (d *diveCommandBuilder) AddBoolFlagWithShortHand(name string, shorthand string, value bool, usage string) CommandBuilder {
panic("not implemented") // TODO: Implement
}

// Build constructs and returns the Cobra command.
func (d *diveCommandBuilder) Build() *cobra.Command {
panic("not implemented") // TODO: Implement
}

// SetUse sets the Use field of the command.
func (d *diveCommandBuilder) SetUse(use string) CommandBuilder {
panic("not implemented") // TODO: Implement
}

// SetShort sets the Short field of the command.
func (d *diveCommandBuilder) SetShort(short string) CommandBuilder {
panic("not implemented") // TODO: Implement
}

// SetLong sets the Long field of the command.
func (d *diveCommandBuilder) SetLong(long string) CommandBuilder {
panic("not implemented") // TODO: Implement
}

// SetRun sets the Run field of the command.
func (d *diveCommandBuilder) SetRun(run func(cmd *cobra.Command, args []string)) CommandBuilder {
panic("not implemented") // TODO: Implement
}
16 changes: 8 additions & 8 deletions cli/common/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ type CommandBuilder interface {
// AddCommand adds a subcommand to the command.
AddCommand(cmd *cobra.Command) CommandBuilder

// Add Persistant Bool Flag
AddBoolPersistantFlag(p *bool, name string, value bool, usage string) CommandBuilder
// Add Persistent Bool Flag
AddBoolPersistentFlag(p *bool, name string, value bool, usage string) CommandBuilder

// Add Persistant Bool Flag with Short hand
AddBoolPersistantFlagWithShortHand(p *bool, name string, value bool, usage string, shorthand string) CommandBuilder
// Add Persistent Bool Flag with Short hand
AddBoolPersistentFlagWithShortHand(p *bool, name string, value bool, usage string, shorthand string) CommandBuilder

// Add Persistant String Flag
AddStringPersistantFlag(p *string, name string, value string, usage string) CommandBuilder
// Add Persistent String Flag
AddStringPersistentFlag(p *string, name string, value string, usage string) CommandBuilder

// Add Persistant String Flag with Short hand
AddStringPersistantFlagWithShortHand(p *string, name string, shorthand string, value string, usage string) CommandBuilder
// Add Persistent String Flag with Short hand
AddStringPersistentFlagWithShortHand(p *string, name string, shorthand string, value string, usage string) CommandBuilder

// Add StringFlag adds a string flag to the command that persists
AddStringFlag(name string, value string, usage string) CommandBuilder
Expand Down

0 comments on commit cd7b56c

Please sign in to comment.