Module: Portage::Cli

Defined in:
lib/portage/cli.rb,
lib/portage/cli/buy.rb,
lib/portage/cli/find.rb,
lib/portage/cli/compare.rb,
lib/portage/cli/history.rb,
lib/portage/cli/version.rb,
lib/portage/cli/probe_cache.rb,
lib/portage/cli/search_backends.rb,
lib/portage/cli/catalog_products.rb,
lib/portage/cli/shipping_profile.rb

Overview

portage — the single command-line entrypoint for acting as a shopper's agent against any store, native-UCP or not. See Cli::Buy for the buying algorithm and Cli::Find for the "I don't have a URL" search that feeds it; this module is just argument parsing + subcommand dispatch.

Defined Under Namespace

Modules: CatalogProducts, SearchBackends, ShippingProfile Classes: Buy, Compare, Find, History, ProbeCache

Constant Summary collapse

USAGE =
<<~USAGE.freeze
  usage: portage buy <url> --query "..." [--qty N] [--payment-token TOKEN]
                            [--product-id ID] [--yes] [--dry-run] [--json]
         portage buy --query "..." [--store URL] [--max-price N] [--limit N] ...
         portage find --query "..." [--max-price N] [--limit N] [--json]
         portage compare <url> --product-id ID [--id VALUE ...] [--results N]
                                [--max-price N] [--json]
         portage history [list] [--purchases|--searches] [--limit N] [--json]
         portage history clear [--purchases|--searches]
USAGE
VERSION =
"0.3.0".freeze

Class Method Summary collapse

Class Method Details

.run(argv) ⇒ Integer

Returns process exit code.

Parameters:

  • argv (Array<String>)

Returns:

  • (Integer)

    process exit code



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/portage/cli.rb', line 31

def self.run(argv)
  command, *rest = argv
  case command
  when "buy" then run_buy(rest)
  when "find" then run_find(rest)
  when "compare" then run_compare(rest)
  when "history" then run_history(rest)
  else
    warn USAGE
    1
  end
end