Skip to content

Commit

Permalink
feat: add version flag
Browse files Browse the repository at this point in the history
  • Loading branch information
natesales committed Dec 31, 2021
1 parent d0e819e commit af7b1e2
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,26 @@ import (

// CLI flags
var opts struct {
Name string `short:"q" long:"qname" description:"Query name"`
Server string `short:"s" long:"server" description:"DNS server"`
Types []string `short:"t" long:"type" description:"RR type"`
Reverse bool `short:"x" long:"reverse" description:"Reverse lookup"`
DNSSEC bool `short:"d" long:"dnssec" description:"Request DNSSEC"`
Format string `short:"f" long:"format" description:"Output format (pretty, json, raw)" default:"pretty"`
Chaos bool `short:"c" long:"chaos" description:"Use CHAOS query class"`
OdohProxy string `short:"p" long:"odoh-proxy" description:"ODoH proxy"`
Insecure bool `short:"i" long:"insecure" description:"Disable TLS certificate verification"`
Timeout uint `long:"timeout" description:"Upstream timeout in seconds" default:"10"`
Verbose bool `short:"v" long:"verbose" description:"Show verbose log messages"`
Name string `short:"q" long:"qname" description:"Query name"`
Server string `short:"s" long:"server" description:"DNS server"`
Types []string `short:"t" long:"type" description:"RR type"`
Reverse bool `short:"x" long:"reverse" description:"Reverse lookup"`
DNSSEC bool `short:"d" long:"dnssec" description:"Request DNSSEC"`
Format string `short:"f" long:"format" description:"Output format (pretty, json, raw)" default:"pretty"`
Chaos bool `short:"c" long:"chaos" description:"Use CHAOS query class"`
OdohProxy string `short:"p" long:"odoh-proxy" description:"ODoH proxy"`
Insecure bool `short:"i" long:"insecure" description:"Disable TLS certificate verification"`
Timeout uint `long:"timeout" description:"Upstream timeout in seconds" default:"10"`
Verbose bool `short:"v" long:"verbose" description:"Show verbose log messages"`
ShowVersion bool `short:"V" long:"version" description:"Show version and exit"`
}

var version = "dev" // Set by build process
// Build process flags
var (
version = "dev"
commit = "unknown"
date = "unknown"
)

// ANSI colors
var colors = map[string]string{
Expand Down Expand Up @@ -65,6 +71,11 @@ func driver(args []string) error {
log.SetLevel(log.DebugLevel)
}

if opts.ShowVersion {
fmt.Printf("https://github.com/natesales/q version %s (%s %s)\n", version, commit, date)
os.Exit(0)
}

// Parse requested RR types
var rrTypes = make(map[uint16]bool)
for _, rrType := range opts.Types {
Expand Down

0 comments on commit af7b1e2

Please sign in to comment.