-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathuaas
executable file
·69 lines (54 loc) · 2.26 KB
/
uaas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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
65
66
67
68
#!/usr/bin/env ruby
#--
# Cloud Foundry
# Copyright (c) [2009-2014] Pivotal Software, Inc. All Rights Reserved.
#
# This product is licensed to you under the Apache License, Version 2.0 (the "License").
# You may not use this product except in compliance with the License.
#
# This product includes a number of subcomponents with
# separate copyright notices and license terms. Your use of these
# subcomponents is subject to the terms and conditions of the
# subcomponent's license, as noted in the LICENSE file.
#++
$:.unshift File.expand_path File.join __FILE__, '..', '..', 'lib'
require 'uaa/stub/uaa'
require 'uaa/cli/base'
require 'uaa/cli/version'
module CF::UAA
Util.default_logger(:trace)
class ServerTopic < Topic
topic "", "run"
desc "version", "Display version" do say "version #{CLI_VERSION}" end
define_option :trace, "--[no-]trace", "-t", "display extra verbose debug information"
define_option :debug, "--[no-]debug", "-d", "display debug information"
define_option :help, "--[no-]help", "-h", "display helpful information"
define_option :version, "--[no-]version", "-v", "show version"
desc "help [topic|command...]", "Display summary or details of command or topic" do |*args|
args.empty? ? say_help : say_command_help(args)
end
define_option :port, "--port <number>", "-p", "port for server to listen on"
define_option :root, "--root <path>", "-r", "root path of UAA resources, e.g. /uaa"
desc "run", "Run the UAA server", :port, :root do
CF::UAA::StubUAA.new(port: (opts[:port] || "8080").to_i, root: opts[:root],
logger: Util.default_logger).run
end
end
class ServerCli < BaseCli
@overview = "UAA Stub Server Command Line\nProvides partial uaa server support suitable for testing uaac."
@topics = [ServerTopic]
@global_options = [:help, :version, :debug, :trace]
@input, @output = $stdin, $stdout
def self.handle_bad_command(args, msg)
@output.puts "\n#{msg}"
run args.unshift("help")
nil
end
def self.preprocess_options(args, opts)
return args.replace(["version"]) if opts[:version]
return args.unshift("help") if args.empty? || opts[:help] && args[0] != "version"
Util.default_logger(opts[:trace]? :trace: opts[:debug]? :debug: :warn, @output)
end
end
end
exit CF::UAA::ServerCli.run ? 0 : 1