Module: ArchSpec::CLI

Extended by:
CLI
Included in:
CLI
Defined in:
lib/archspec/cli.rb

Overview

The archspec command line. Backs the exe/archspec executable and dispatches the init, check, explain, and version subcommands.

archspec init
archspec check [PATHS...] [--config PATH] [--format text|json] [--update-todo]
archspec explain PATH_OR_CONSTANT

#run returns the process exit status: 0 when clean, 1 when violations are found.

Constant Summary collapse

CONFIG_FILE =
'Archspec.rb'
TEMPLATE =
<<~RUBY
  architecture :rails
RUBY

Instance Method Summary collapse

Instance Method Details

#run(argv, output: $stdout, error: $stderr) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/archspec/cli.rb', line 23

def run(argv, output: $stdout, error: $stderr)
  argv = argv.dup
  command = argv.shift || 'check'

  case command
  when 'init'
    init(argv, output)
  when 'check'
    check(argv, output)
  when 'explain'
    explain(argv, output)
  when 'version', '--version', '-v'
    output.puts ArchSpec::VERSION
    0
  else
    error.puts "Unknown command: #{command}"
    error.puts usage
    64
  end
rescue Error => e
  error.puts e.message
  1
end