Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change cli option dns-type(-d/--dns-type) #4

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ doh.aaaa
### CLI
- Usage
```
# ddig --help
$ ddig --help
Usage: ddig [options] hostname
-t, --type={all|do53|dot} resolve type (default: all)
-d, --dns-type={all|do53|dot} resolve type (default: all)
--udp use resolve type of udp(do53)
--dot use resolve type of dot
--doh-h1 use resolve type of doh (http/1.1)
Expand Down
12 changes: 6 additions & 6 deletions lib/ddig/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Cli
def initialize(args)
@args = args
@options = {
type: 'all',
dns_type: 'all',
format: 'text',
}

Expand All @@ -23,10 +23,10 @@ def parse_options
@option_parser = OptionParser.new do |opts|
opts.banner = "Usage: ddig [options] hostname"

opts.on("-t", "--type={all|do53|dot}", "resolve type (default: all)") { |v| @options[:type] = v }
opts.on("--udp", "use resolve type of udp(do53)") { |v| @options[:type] = 'do53' }
opts.on("--dot", "use resolve type of dot") { |v| @options[:type] = 'dot' }
opts.on("--doh-h1", "use resolve type of doh (http/1.1)") { |v| @options[:type] = 'doh_h1' }
opts.on("-d", "--dns-type={all|do53|dot}", "resolve type (default: all)") { |v| @options[:dns_type] = v }
opts.on("--udp", "use resolve type of udp(do53)") { |v| @options[:dns_type] = 'do53' }
opts.on("--dot", "use resolve type of dot") { |v| @options[:dns_type] = 'dot' }
opts.on("--doh-h1", "use resolve type of doh (http/1.1)") { |v| @options[:dns_type] = 'doh_h1' }
opts.on("--doh-path=doh-path", "doh service path") { |v| @options[:doh_path] = v }
opts.on("-4", "--ipv4", "use IPv4 query transport only") { |v| @options[:ipv4] = v }
opts.on("-6", "--ipv6", "use IPv6 query transport only") { |v| @options[:ipv6] = v }
Expand All @@ -52,7 +52,7 @@ def exec
@use_ipv6 = @options[:ipv6] || false
end

case @options[:type]
case @options[:dns_type]
when "all"
resolve_all
when "do53"
Expand Down