| 1 |
#!/usr/bin/env python3 |
| 2 |
# This file is part of kytos-utils. |
| 3 |
# |
| 4 |
# Copyright (c) 2016-2019 by Kytos Team. |
| 5 |
# |
| 6 |
# Authors: |
| 7 |
# Beraldo Leal <beraldo AT ncc DOT unesp DOT br> |
| 8 |
|
| 9 |
"""kytos - The kytos command line. |
| 10 |
|
| 11 |
Usage: kytos [-c <file>|--config <file>] <command> [<args>...] |
| 12 |
kytos [-v|--version] |
| 13 |
kytos [-h|--help] |
| 14 |
|
| 15 |
Options: |
| 16 |
-c <file>, --config <file> Load config file [default: ~/.kytosrc] |
| 17 |
-h, --help Show this screen. |
| 18 |
-v, --version Show version. |
| 19 |
|
| 20 |
The most commonly used kytos commands are: |
| 21 |
napps Create, list, enable, install (and other actions) NApps. |
| 22 |
server Start, Stop your Kytos Controller (Kytos) |
| 23 |
web Manage the Web User Interface |
| 24 |
users Commands to handle users from NApps server. |
| 25 |
|
| 26 |
See 'kytos <command> -h|--help' for more information on a specific command. |
| 27 |
""" |
| 28 |
import logging |
| 29 |
import os |
| 30 |
|
| 31 |
from docopt import docopt |
| 32 |
from kytos.utils.config import KytosConfig |
| 33 |
|
| 34 |
logging.basicConfig(format='%(levelname)-5s %(message)s', level=logging.INFO) |
| 35 |
|
| 36 |
if __name__ == '__main__': |
| 37 |
metadata = KytosConfig().get_metadata() |
| 38 |
version = metadata.get('__version__') |
| 39 |
|
| 40 |
args = docopt(__doc__, |
| 41 |
version='kytos command line, version %s' % version, |
| 42 |
options_first=True) |
| 43 |
command = args['<command>'] |
| 44 |
command_args = args['<args>'] |
| 45 |
argv = [command] + command_args |
| 46 |
|
| 47 |
if command == 'napps': |
| 48 |
from kytos.cli.commands.napps.parser import parse |
| 49 |
|
| 50 |
parse(argv) |
| 51 |
elif command == 'users': |
| 52 |
from kytos.cli.commands.users.parser import parse |
| 53 |
|
| 54 |
parse(argv) |
| 55 |
elif command == 'web': |
| 56 |
from kytos.cli.commands.web.parser import parse |
| 57 |
|
| 58 |
parse(argv) |
| 59 |
else: |
| 60 |
print("Error: Invalid syntax") |
| 61 |
exit(__doc__) |