Class: Pakyow::CLI Private

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

The Pakyow command line interface.

Defined Under Namespace

Classes: InvalidInput

Constant Summary collapse

GLOBAL_OPTIONS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

{
  app: {
    description: "The app to run the command on",
    global: true
  }.freeze,
  env: {
    description: "What environment to use",
    global: true
  }.freeze
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(argv = ARGV.dup) ⇒ CLI

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of CLI.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/pakyow/cli.rb', line 29

def initialize(argv = ARGV.dup)
  @argv = argv
  @options = {}
  @task = nil
  @command = nil

  parse_global_options

  if project_context?
    setup_environment
  end

  load_tasks

  if @command
    find_task_for_command
    set_app_for_command
    call_task
  else
    puts_help
  end
rescue StandardError => error
  if $stdout.isatty
    puts_error(error)

    if @task
      puts @task.help(describe: false)
    else
      puts_help(banner: false)
    end

    ::Process.exit(0)
  else
    raise error
  end
end