Sha256: a0efebec13352d0d56bcd1f54d91d316bee38640c7735f594c67a3c7a7bf4629

Contents?: true

Size: 1.39 KB

Versions: 1

Compression:

Stored size: 1.39 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
require 'bundler'
Bundler.require(:default)

require 'paint'
require 'color'

require 'pedrozath-mercenary'
require 'coltrane/commands'

Paint.mode = 0xFFFFFF

Mercenary.program(:Coltrane) do |p|
  p.version Coltrane::VERSION
  p.description <<~DESC
    A music querying interface
    by Pedro Maciel (pedro@pedromaciel.com)

    Check the chat room for project help/discussion/contribution: https://coltrane-ruby.herokuapp.com
  DESC
  p.syntax 'coltrane <subcommand> [options]'

  Coltrane::Commands::Command.subclasses.each do |command|
    command.mercenary_init(p)
  end

  p.command(:about) do |c|
    c.description 'Shows this screen'
    c.action { puts p }
  end

  p.command(:shell) do |c|
    c.description 'Starts an interactive shell'
    c.action do
      system File.expand_path('../../bin', __FILE__) + "/coltrane-interactive"
    end
  end

  p.command(:help) do |c|
    c.description 'May give you some help.'
    c.syntax 'help <command> [subcommand, sub-subcommand, ...]'
    c.action do |(*command_path), _options|
      if command_path.empty?
        puts p
      else
        puts begin
          command_path.reduce(p) do |memo, key|
            memo.commands.delete(key.to_sym)
          end || "\n Sorry, command found."
        end
      end
    end
  end

  p.default_command(:shell)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
coltrane-3.1.1 exe/coltrane