Module: Rubyists::Linear::CLI

Extended by:
Dry::CLI::Registry
Includes:
SemanticLogger::Loggable
Defined in:
lib/linear/cli.rb,
lib/linear/cli.rb,
lib/linear/cli/caller.rb,
lib/linear/cli/watcher.rb,
lib/linear/cli/what_for.rb,
lib/linear/commands/team.rb,
lib/linear/commands/issue.rb,
lib/linear/commands/whoami.rb,
lib/linear/cli/sub_commands.rb,
lib/linear/commands/console.rb,
lib/linear/commands/version.rb,
lib/linear/commands/issue/pr.rb,
lib/linear/cli/common_options.rb,
lib/linear/commands/team/list.rb,
lib/linear/commands/issue/list.rb,
lib/linear/commands/issue/take.rb,
lib/linear/commands/issue/create.rb,
lib/linear/commands/issue/update.rb,
lib/linear/commands/issue/develop.rb

Overview

Namespace for CLI

Defined Under Namespace

Modules: Caller, CommonOptions, Issue, SubCommands, Team, Watcher, WhatFor Classes: Console, Version, WhoAmI

Class Method Summary collapse

Class Method Details

.load_and_register!(command) ⇒ Object



74
75
76
77
78
79
80
# File 'lib/linear/cli.rb', line 74

def self.load_and_register!(command)
  name = command.name.split('::').last.downcase
  command_aliases = command::ALIASES[name.to_sym] || []
  register name, aliases: Array(command_aliases) do |cmd|
    register_subcommands! cmd, name, command
  end
end

.promptObject



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

def self.prompt
  return @prompt if @prompt

  @prompt = TTY::Prompt.new
  # This gives ex/vim style navigation to menus
  @prompt.on(:keypress) do |event|
    @prompt.trigger(:keydown) if event.value == 'j'
    @prompt.trigger(:keyup) if event.value == 'k'
  end
  @prompt
end

.register_sub!(command, sub_file, klass) ⇒ Object



56
57
58
59
60
61
62
63
64
65
# File 'lib/linear/cli.rb', line 56

def self.register_sub!(command, sub_file, klass)
  # The filename is expected to define a class of the same name, but capitalized
  name = sub_file.basename('.rb').to_s
  subklass = klass.const_get(name.capitalize)
  if (aliases = klass::ALIASES[name.to_sym])
    command.register name, subklass, aliases: Array(aliases)
  else
    command.register name, subklass
  end
end

.register_subcommands!(command, name, klass) ⇒ Object



67
68
69
70
71
72
# File 'lib/linear/cli.rb', line 67

def self.register_subcommands!(command, name, klass)
  Pathname.new(__FILE__).dirname.join("commands/#{name}").glob('*.rb').each do |file|
    require file.expand_path
    register_sub! command, file, klass
  end
end