3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 from __future__ import print_function
18 from lockcli import handlers as clihandlers
21 class CLIProcessor(object):
22 def __init__(self, prog):
25 def __call__(self, args):
26 parser = argparse.ArgumentParser(description='Lock CLI', prog=self.prog)
27 parser.add_argument('--server',
35 parser.add_argument('--port',
43 parser.add_argument('--verbose',
48 subparsers = parser.add_subparsers()
49 handlers = clihandlers.get_handlers_list()
50 for handler in handlers:
51 handler.init_subparser(subparsers)
53 parse_result = parser.parse_args(args)
55 parse_result.handler(parse_result)
59 processor = CLIProcessor('lockcli')
63 except Exception as error: # pylint: disable=broad-except
64 print('Got error %s' % str(error))
68 if __name__ == '__main__':