Skip to content

Commit

Permalink
refactor: rename Option field to Name
Browse files Browse the repository at this point in the history
- Changed field name from Option to Name in the Options array for consistency.
  • Loading branch information
RaulCatalinas committed Aug 16, 2024
1 parent 613fb7f commit 2f41dc3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion internal/cli/show_help.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func ShowHelp() {
fmt.Println("Options:")

for _, option := range constants.Options {
fmt.Printf("%-15s %-5s %s\n", option.Option, option.Alias, option.Description)
fmt.Printf("%-15s %-5s %s\n", option.Name, option.Alias, option.Description)
}

fmt.Println()
Expand Down
13 changes: 9 additions & 4 deletions internal/config/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,23 @@ import (
func ConfigureOptions() {
if len(os.Args) != 2 {
cli.ShowHelp()

os.Exit(0)
}

switch os.Args[1] {
case constants.Options[1].Option, constants.Options[1].Alias:
case constants.Options[1].Name, constants.Options[1].Alias:
handlers.HandlerOptionCollaborate()
case constants.Options[2].Option, constants.Options[2].Alias:

case constants.Options[2].Name, constants.Options[2].Alias:
handlers.HandlerOptionBuild()
case constants.Options[0].Option, constants.Options[0].Alias:

case constants.Options[0].Name, constants.Options[0].Alias:
cli.ShowVersion()
case constants.Options[3].Option, constants.Options[3].Alias:

case constants.Options[3].Name, constants.Options[3].Alias:
cli.ShowHelp()

default:
cli.ShowHelp()
}
Expand Down
8 changes: 4 additions & 4 deletions internal/constants/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ import "github.com/RaulCatalinas/HuskyBC/internal/types"

var Options = []types.Option{
{
Option: "--version",
Name: "--version",
Alias: "-v",
Description: "Output the version number",
},
{
Option: "--collaborate",
Name: "--collaborate",
Alias: "-co",
Description: "Open GitHub repository for collaboration",
},
{
Option: "--build",
Name: "--build",
Alias: "-b",
Description: "Start Husky's configuration",
},
{
Option: "--help",
Name: "--help",
Alias: "-h",
Description: "Display help for command",
},
Expand Down
4 changes: 2 additions & 2 deletions internal/types/cli.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package types

type Option struct {
Option string
Name string
Alias string
Description string
}
}

0 comments on commit 2f41dc3

Please sign in to comment.