Class: RubyLens::CLI

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

Constant Summary collapse

COMMANDS =

One entry per generating command: everything that differs between report, showcase, and clip lives here, not in per-command methods.

{
  "report" => {
    default_name: Generator::DEFAULT_REPORT_NAME,
    generator: :generate_report,
    warning: "RubyLens reports contain private codebase structure. Keep the output local unless you intend to share it.",
    details_option: false,
    output_kind: "HTML",
    report_progress: false,
  },
  "clip" => {
    default_name: ClipGenerator::DEFAULT_CLIP_NAME,
    generator: :generate_clip,
    warning: "RubyLens clips show the same picture as showcases: the project name plus the galaxy's shape and scale; --details adds aggregate statistics and selected Ruby and dependency names. Share them intentionally.",
    details_option: true,
    output_kind: "MP4",
    report_progress: true,
  },
  "showcase" => {
    default_name: ShowcaseGenerator::DEFAULT_SHOWCASE_NAME,
    generator: :generate_showcase,
    warning: "RubyLens showcases disclose the project name and visual codebase structure; --details also includes aggregate statistics and selected Ruby and dependency names. Share them intentionally.",
    details_option: true,
    output_kind: "HTML",
    report_progress: false,
  },
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(arguments) ⇒ CLI

Returns a new instance of CLI.



38
39
40
# File 'lib/rubylens/cli.rb', line 38

def initialize(arguments)
  @arguments = arguments.dup
end

Instance Method Details

#runObject



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/rubylens/cli.rb', line 42

def run
  arguments = @arguments.dup
  command = arguments.shift
  return print_version if %w[-v --version version].include?(command)
  return print_help(0) if command.nil? || %w[-h --help help].include?(command)
  return generate(command, arguments) if COMMANDS.key?(command)

  $stderr.puts "Unknown command: #{command}"
  print_help(2)
rescue OptionParser::ParseError, Error, Errno::ENOENT => error
  $stderr.puts "rubylens: #{error.message}"
  2
end