86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
# File 'lib/fenris/command.rb', line 86
def self.parse(args)
= []
options = OpenStruct.new
options.port = 10001
options.host = Socket.gethostname
options.user = ENV['FENRIS_USER']
options.password = ENV['FENRIS_AUTHKEY']
options.config = ENV['FENRIS_CONFIG'] || "#{ENV["HOME"]}/.fenris"
options.debug = !! ENV['FENRIS_DEBUG']
options.autosync = true
if i = args.index("exec")
= args[i..(args.length)]
if i > 0
args = args[0..(i-1)]
else
args = []
end
end
opts = OptionParser.new do |opts|
opts.banner = "Usage: fenris [options] COMMAND"
opts.separator ""
opts.separator "Commands:"
opts.separator ""
opts.separator " fenris info # info about current user and connections"
opts.separator " fenris useradd NAME # create a new subaccount"
opts.separator " fenris userdel NAME # delete a subaccount"
opts.separator " fenris add USER # allow USER to consume service"
opts.separator " fenris remove USER # disallow USER to consume service"
opts.separator " fenris provide BINDING # provide a local service"
opts.separator " fenris consume [ USER [ BINDING ] ] # consume one (or all) remote services"
opts.separator " fenris exec COMMAND # consume services and run COMMAND. Terminates when command exits."
opts.separator " fenris sync # sync config with broker"
opts.separator " fenris rekey # generate a new authkey for the user"
opts.separator " fenris bind USER BINDING # bind a remote service to a local binding"
opts.separator ""
opts.separator "Bindings can take the form of:"
opts.separator ""
opts.separator " PORT, :PORT, HOST:PORT, /PATH/TO/UNIX_SOCKET, or -- for STDIN"
opts.separator ""
opts.separator "Options:"
opts.on("-u", "--user USER", "Connect as USER. Default is $FENRIS_USER.") do |user|
options.user = user
end
opts.on("-c", "--config DIR", "Store config information in DIR. Default is $HOME/.fenris or $FENRIS_CONFIG.") do |dir|
options.config = dir
end
opts.on("-h", "--hostname HOST", "Hostname given to consumers on 'provide'. Default is `hostname`.") do |host|
options.host = host
end
opts.on("-p", "--port PORT", "") do |port|
options.port = port
end
opts.on("-q", "--quiet", "Do not print log messages.") do
options.quiet = true
end
opts.on("-d", "--debug", "Print debugging messages. Default is $FENRIS_DEBUG.") do
options.debug = true
end
opts.on("-a", "--[no-]autosync", "Automatically sync updates from the broker. Default is true.") do |auto|
options.autosync = auto
end
opts.on("-h", "--help", "Show this message") do
puts opts
exit
end
opts.on("--version", "Show version") do
puts Fenris::VERSION
exit
end
opts.separator ""
end
begin
commands = opts.parse!(args)
rescue OptionParser::InvalidOption
puts opts
exit
end
[ commands + , options, opts.to_s ]
end
|