Sha256: a42e19ce91f4d2cb49d048757375e194366cb7324751cf259ec400768880c181

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

#!/usr/bin/env ruby
# DuckGo is a RubyGem library and command line tool for searching with DuckDuckGo.
# By default, it puts out only the relevant information, but when told, it will dump
# all the data you could ask for. This tool aims to give access to most of the
# features from the official API.
# Daniel Ethridge

require "duckgo"
include DuckGo
require "duckgo/version"

# If there are no arguments...
if ARGV.length == 0
  puts "Hmm..."
  exit
end

help = """DuckGo lets you search duckduckgo.com for instant answers

duckgo something searchable         :  Auto-handle the search
duckgo [--help | -h]                :  Display this help
duckgo [--version | -V]             :  Display version
duckgo [--favicon | -f] google.com  :  Get google's favicon
duckgo \\!gem duckgo                 :  Use !bang syntax to search a specific site

View docs and API on https://github.com/wlib/duckgo
Made by Daniel Ethridge | git.io/de
"""

# Argument "parser" if you want to call it that
case ARGV[0]
  when "--help", "-h"
    puts help
    exit
  when "--version", "-V"
    puts "DuckGo v#{VERSION}"
    exit
  when "--favicon", "-f"
    site = ARGV[1]
    file = File.open("#{site}-favicon.ico", "w")
    favicon = get_favicon(site)
    file.write(favicon)
    puts "Queried favicon from #{site}."
    file.close
    exit
  else
    handle(ARGV[0..-1].join(" "))
    exit
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
duckgo-1.2.0 bin/duckgo