Skip to content

Commit

Permalink
feat: config command
Browse files Browse the repository at this point in the history
  • Loading branch information
Shawn Yu authored and Shawn Yu committed May 13, 2024
1 parent efb4e3b commit 17eeb21
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
39 changes: 39 additions & 0 deletions golang/cmd/config/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package config

import (
"github.com/charmbracelet/log"
"github.com/shawnyu5/gh-ac/cmd"
"github.com/shawnyu5/gh-ac/config"
"github.com/spf13/cobra"
)

type cmdFlags struct {
hostName string
}

var flags cmdFlags

type Config struct {
// Custom hostname to run gh cli commands with
HostName string
}

// configCmd represents the config command
var configCmd = &cobra.Command{
Use: "config",
Short: "Set config values",
Run: func(cmd *cobra.Command, args []string) {
err := config.Write(config.Config{
HostName: flags.hostName,
})
log.Infof("Hostname set to %s", flags.hostName)
if err != nil {
log.Fatalf("Failed to write to config: %w", err)
}
},
}

func init() {
cmd.RootCmd.AddCommand(configCmd)
configCmd.Flags().StringVar(&flags.hostName, "hostname", "", "set the hostname")
}
1 change: 1 addition & 0 deletions golang/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"github.com/shawnyu5/gh-ac/cmd"
_ "github.com/shawnyu5/gh-ac/cmd/config"
_ "github.com/shawnyu5/gh-ac/cmd/push"
)

Expand Down

0 comments on commit 17eeb21

Please sign in to comment.