#!/usr/local/bin/python3.6
# You may redistribute this program and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import cjdns
import argparse
import json

parser = argparse.ArgumentParser(description='Send commands to cjdns')
parser.add_argument('command', metavar='command()',
                    help='The command to send to cjdns')

args = parser.parse_args()


cjdns = cjdns.connectWithAdminInfo()
result = eval("cjdns.%s" % args.command)

if args.command != "functions()":
    print(json.dumps(result, indent=2, separators=(',', ': ')))
