Skip to content

Commit

Permalink
feat: birdsh fall back to config bird-socket option if flag not set (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
natesales committed Jul 15, 2023
1 parent 790d4dc commit bb4735d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cmd/birdsh.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,22 @@ import (
var socket = ""

func init() {
birdshCmd.Flags().StringVarP(&socket, "socket", "s", "/var/run/bird/bird.ctl", "BIRD socket")
birdshCmd.Flags().StringVarP(&socket, "socket", "s", "", "BIRD socket file, will read from bird-socket config option if empty")
rootCmd.AddCommand(birdshCmd)
}

var birdshCmd = &cobra.Command{
Use: "birdsh",
Short: "Lightweight BIRD shell",
Run: func(cmd *cobra.Command, args []string) {
if socket == "" {
conf, err := loadConfig()
if err != nil {
log.Fatal(err)
}
socket = conf.BIRDSocket
}

c, err := net.Dial("unix", socket)
if err != nil {
log.Fatal(err)
Expand Down

0 comments on commit bb4735d

Please sign in to comment.