Sha256: 8eff834ce434242a3e6403573222da2220623501b42be539393396178fe364a2
Contents?: true
Size: 970 Bytes
Versions: 110
Compression:
Stored size: 970 Bytes
Contents
# frozen_string_literal: true module J1 module Commands class Help < Command class << self def init_with_program(prog) prog.command(:help) do |c| c.syntax "help [subcommand]" c.description "Show the help message, optionally for a given subcommand" c.action do |args, _| cmd = (args.first || "").to_sym if args.empty? J1.logger.info prog.to_s elsif prog.has_command? cmd J1.logger.info prog.commands[cmd].to_s else invalid_command(prog, cmd) abort end end end end def invalid_command(prog, cmd) J1.logger.error "Error:", "Hmm... we don't know what the '#{cmd}' command is." J1.logger.info "Valid commands:", prog.commands.keys.join(", ") end end end end end
Version data entries
110 entries across 110 versions & 1 rubygems