Skip to content

Commit

Permalink
Fix #50 - don't require a connection to show lc-admin help
Browse files Browse the repository at this point in the history
  • Loading branch information
driskell committed Sep 29, 2014
1 parent 7c51deb commit c241961
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/lc-admin/lc-admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,7 @@ func (a *Admin) ProcessCommand(command string) bool {
a.renderSnap(" ", snap)
}
case "help":
fmt.Printf("Available commands:\n")
fmt.Printf(" reload Reload configuration\n")
fmt.Printf(" status Display the current shipping status\n")
fmt.Printf(" exit Exit\n")
PrintHelp()
default:
fmt.Printf("Unknown command: %s\n", command)
}
Expand Down Expand Up @@ -231,6 +228,13 @@ WatchLoop:
return true
}

func PrintHelp() {
fmt.Printf("Available commands:\n")
fmt.Printf(" reload Reload configuration\n")
fmt.Printf(" status Display the current shipping status\n")
fmt.Printf(" exit Exit\n")
}

func main() {
var version bool
var quiet bool
Expand All @@ -253,10 +257,16 @@ func main() {
fmt.Printf("Log Courier version %s client\n\n", core.Log_Courier_Version)
}

admin := NewAdmin(quiet, admin_connect)

args := flag.Args()

if len(args) != 0 {
// Don't require a connection to display the help message
if args[0] == "help" {
PrintHelp()
os.Exit(0)
}

admin := NewAdmin(quiet, admin_connect)
if admin.argsCommand(args, watch) {
os.Exit(0)
}
Expand All @@ -273,6 +283,7 @@ func main() {
os.Exit(1)
}

admin := NewAdmin(quiet, admin_connect)
if err := admin.connect(); err != nil {
return
}
Expand Down

0 comments on commit c241961

Please sign in to comment.