Skip to content

Commit

Permalink
Merge pull request #77 from luthermonson/fix-tempdir
Browse files Browse the repository at this point in the history
adding debug and quiet flags
  • Loading branch information
luthermonson authored Dec 18, 2021
2 parents 81574ec + 52c17f1 commit 9e62b65
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@ DESCRIPTION:
Rancher Wins Component (...)
COMMANDS:
srv, server
cli, client
help, h Shows a list of commands or help for one command
srv, server
cli, client
up, upgrade Manage Rancher Wins Application
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--debug Turn on verbose debug logging
--quiet Turn on off all logging
--help, -h show help
--version, -v print the version
```

#### Server (run on Windows host)
Expand Down Expand Up @@ -76,7 +80,7 @@ OPTIONS:

``` powershell
# [host] start the wins server
> wins.exe srv app run --log-level debug --listen rancher_wins
> wins.exe --debug srv app run --listen rancher_wins
# [host] verify the created npipe
> Get-ChildItem //./pipe/ | Where-Object Name -eq "rancher_wins"
Expand Down
30 changes: 25 additions & 5 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"fmt"
"io"
"io/ioutil"
"os"

"github.com/mattn/go-colorable"
Expand All @@ -13,6 +14,7 @@ import (
"github.com/rancher/wins/pkg/panics"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
"google.golang.org/grpc"
)

func main() {
Expand Down Expand Up @@ -49,16 +51,34 @@ func main() {
}

app.Commands = []cli.Command{
// server
server.NewCommand(),

// cli
client.NewCommand(),

// upgrade
upgrade.NewCommand(),
}

app.Flags = []cli.Flag{
&cli.BoolFlag{
Name: "debug",
Usage: "Turn on verbose debug logging",
},
&cli.BoolFlag{
Name: "quiet",
Usage: "Turn on off all logging",
},
}

app.Before = func(c *cli.Context) error {
if c.Bool("debug") {
logrus.SetLevel(logrus.DebugLevel)
grpc.EnableTracing = true
}
if c.Bool("quiet") {
logrus.SetOutput(ioutil.Discard)
}

return nil
}

if err := app.Run(os.Args); err != nil && err != io.EOF {
logrus.Fatal(err)
}
Expand Down

0 comments on commit 9e62b65

Please sign in to comment.