Class: Multidocs::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/multidocs/cli.rb

Overview

command dispatcher for the multidocs executable.

Constant Summary collapse

USAGE =
<<~TEXT
  multidocs #{VERSION} — kujo documentation toolchain

  usage:
    multidocs build   run the rust helper binary (multidocs --version)
    multidocs serve   serve ../public_html on http://localhost:8080
    multidocs help    show this message
TEXT
BINARY_CANDIDATES =

candidate locations for the rust binary, first match wins:

1. MULTIDOCS_BIN env override
2. dev build inside the repo (rust/target/release)
3. release binary dropped next to the gem
4. anything on PATH named multidocs-bin
[
  ENV["MULTIDOCS_BIN"],
  File.expand_path("../../../rust/target/release/multidocs", __dir__),
  File.expand_path("../../bin/multidocs-bin", __dir__),
  "multidocs-bin"
].compact.freeze
DEFAULT_PORT =
8080

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ CLI

Returns a new instance of CLI.



35
36
37
# File 'lib/multidocs/cli.rb', line 35

def initialize(argv)
  @argv = argv
end

Instance Method Details

#runObject



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/multidocs/cli.rb', line 39

def run
  case @argv.first
  when "build" then build
  when "serve" then serve
  when "help", "-h", "--help", nil then puts USAGE
  else
    warn "multidocs: unknown command #{@argv.first.inspect}"
    warn USAGE
    1
  end || 0
end