# -*- coding: utf-8 -*-
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

# Use following rules for versioning:
# <cloudstack major version>.<cloudstack minor version>.<cli increment>
__version__ = "4.0.0"

try:
    import os
    from precache import precached_verbs
except ImportError, e:
    precached_verbs = {}

# Add config key:value
config_file = os.path.expanduser('~/.cloudmonkey_config')
config_fields = {'host': 'localhost', 'port': '8080',
                 'protocol': 'http', 'path': '/client/api',
                 'apikey': '', 'secretkey': '',
                 'timeout': '3600', 'asyncblock': 'true',
                 'prompt': '🐵 cloudmonkey>', 'color': 'true',
                 'tabularize': 'false',
                 'log_file':
                 os.path.expanduser('~/.cloudmonkey_log'),
                 'history_file':
                 os.path.expanduser('~/.cloudmonkey_history')}


@@ -859,22 +859,16 @@
 ack 
-major 
 version%3E
 .%3Ccl
@@ -867,50 +867,38 @@
 ion%3E
-.%3Ccloudstack minor version%3E.%3Ccli increment
+-%3Ccli increment, starts from 0
 %3E%0A__
@@ -916,10 +916,12 @@
  %224.
-0.
+1.0-
 0%22%0A%0A
@@ -925,16 +925,51 @@
 %22%0A%0Atry:%0A
+    from os.path import expanduser%0A
     impo
@@ -1068,30 +1068,187 @@
 %7B%7D%0A%0A
-# Add config key:value
+param_type = %5B'boolean', 'date', 'float', 'integer', 'short', 'list',%0A              'long', 'object', 'map', 'string', 'tzdate', 'uuid'%5D%0A%0Aconfig_dir = expanduser('~/.cloudmonkey')
 %0Acon
@@ -1258,24 +1258,16 @@
 _file = 
-os.path.
 expandus
@@ -1261,36 +1261,59 @@
 le = expanduser(
-'~/.
+config_dir + '/config')%0A%0A# 
 cloudmonkey_conf
@@ -1311,17 +1311,22 @@
 nkey
-_
+ 
 config
-')
+ fields
 %0Acon
@@ -1344,289 +1344,380 @@
 = %7B'
-host': 'localhost', 'port': '8080',%0A                 'protocol': 'http', 'path': '/client/api',%0A                 'apikey': '', 'secretkey': '',%0A                 'timeout': '3600', 'asyncblock': 'true',%0A                 'prompt': '%F0%9F%90%B5 cloudmonkey%3E', 'color': 'true',%0A                 
+core': %7B%7D, 'ui': %7B%7D, 'server': %7B%7D, 'user': %7B%7D%7D%0A%0A# core%0Aconfig_fields%5B'core'%5D%5B'cache_file'%5D = expanduser(config_dir + '/cache')%0Aconfig_fields%5B'core'%5D%5B'history_file'%5D = expanduser(config_dir + '/history')%0Aconfig_fields%5B'core'%5D%5B'log_file'%5D = expanduser(config_dir + '/log')%0A%0A# ui%0Aconfig_fields%5B'ui'%5D%5B'color'%5D = 'true'%0Aconfig_fields%5B'ui'%5D%5B'prompt'%5D = '%3E '%0Aconfig_fields%5B'ui'%5D%5B
 'tab
@@ -1728,17 +1728,19 @@
 ize'
-:
+%5D =
  'false'
 ,%0A  
@@ -1739,191 +1739,371 @@
 lse'
-,%0A                 'log_file':%0A                 os.path.expanduser('~/.cloudmonkey_log'),%0A                 'history_file':%0A                 os.path.expanduser('~/.cloudmonkey_history')%7D%0A
+%0A%0A# server%0Aconfig_fields%5B'server'%5D%5B'asyncblock'%5D = 'true'%0Aconfig_fields%5B'server'%5D%5B'host'%5D = 'localhost'%0Aconfig_fields%5B'server'%5D%5B'path'%5D = '/client/api'%0Aconfig_fields%5B'server'%5D%5B'port'%5D = '8080'%0Aconfig_fields%5B'server'%5D%5B'protocol'%5D = 'http'%0Aconfig_fields%5B'server'%5D%5B'timeout'%5D = '3600'%0A%0A# user%0Aconfig_fields%5B'user'%5D%5B'apikey'%5D = ''%0Aconfig_fields%5B'user'%5D%5B'secretkey'%5D = ''
 %0A

Fix common.py's cfg fields grouped under similarites like ui, core, user etc.