Module: Portage::Cli

Defined in:
lib/portage/cli.rb,
lib/portage/cli/buy.rb,
lib/portage/cli/find.rb,
lib/portage/cli/version.rb,
lib/portage/cli/probe_cache.rb,
lib/portage/cli/search_backends.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: SearchBackends Classes: Buy, Find, 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]
USAGE
VERSION =
"0.1.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



23
24
25
26
27
28
29
30
31
32
# File 'lib/portage/cli.rb', line 23

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