Module: Uma::CLI
- Defined in:
- lib/uma/cli.rb,
lib/uma/cli/error.rb
Defined Under Namespace
Modules: Error
Classes: Base, ErrorResponse, Help, Serve, Version
Constant Summary
collapse
- CLI_HELP =
<<~EOF
●
●╭───╮●
│UMA│ A modern web server for Ruby
●╰───╯● https://uma.noteflakes.com/
●
Uma version #{Uma::VERSION}
Usage: uma <COMMAND>
Commands:
serve Run a Rack application
help Print this message or the help of the given subcommand(s)
EOF
- ERROR_RESPONSE_TEMPLATE =
<<~EOF
Error: %<error_msg>s
Usage: uma <COMMAND>
Commands:
serve Run a Rack application
help Print this message or the help of the given subcommand(s)
EOF
- SERVE_BANNER =
<<~EOF
●
●╭───╮●
│UMA│ A modern web server for Ruby
●╰───╯● https://uma.noteflakes.com/
●
Uma version #{Uma::VERSION}
EOF
Class Method Summary
collapse
Class Method Details
.call(argv, env) ⇒ Object
11
12
13
14
15
|
# File 'lib/uma/cli.rb', line 11
def self.call(argv, env)
setup_controller(argv, env).tap {
it.run if !env[:norun]
}
end
|
.setup_controller(argv, env) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/uma/cli.rb', line 17
def self.setup_controller(argv, env)
cmd = argv[0]
argv = argv[1..-1]
case cmd
when 'help'
Help.new(argv, env)
when 'serve'
Serve.new(argv, env)
when 'version'
Version.new(argv, env)
when '', nil
raise Error::NoCommand, ''
else
raise Error::InvalidCommand, "unrecognized command '#{cmd}'"
end
rescue => e
if env[:error_handler]
env[:error_handler].(e)
else
ErrorResponse.new(e, argv, env)
end
end
|