Fixed help appearance on empty/unknown commands

Change-Id: I709e05b3c2658da7a8b257e2970f5f4da2e05cf2
Related-PROD: PROD-35610
diff --git a/cfg_checker/cfg_check.py b/cfg_checker/cfg_check.py
index 2ce37eb..11190b4 100644
--- a/cfg_checker/cfg_check.py
+++ b/cfg_checker/cfg_check.py
@@ -2,7 +2,8 @@
 import sys
 from logging import DEBUG, INFO
 
-from cfg_checker.cli.command import execute_command, helps, parsers
+from cfg_checker.cli.command import execute_command, helps, parsers, \
+    parsers_inits
 from cfg_checker.common import config, logger, logger_cli
 from cfg_checker.helpers.args_utils import MyParser
 
@@ -54,7 +55,7 @@
             _command,
             help=helps[_command]
         )
-        parsers[_command](_parser)
+        parsers[_command] = parsers_inits[_command](_parser)
 
     # parse arguments
     try:
@@ -71,6 +72,10 @@
         )
         sys.exit(1)
 
+    if not args.command:
+        parser.print_help()
+        logger_cli.info("\n# Please, type a command listed above")
+        sys.exit(1)
     # Pass externally configured values
     config.ssh_uses_sudo = args.sudo
 
diff --git a/cfg_checker/cli/command.py b/cfg_checker/cli/command.py
index 0a892d8..f98e608 100644
--- a/cfg_checker/cli/command.py
+++ b/cfg_checker/cli/command.py
@@ -12,6 +12,7 @@
 mods_prefix = mods_import_path + '.'
 
 commands = {}
+parsers_inits = {}
 parsers = {}
 helps = {}
 # Pure dynamic magic, loading all 'do_*' methods from available modules
@@ -26,21 +27,24 @@
         # A package! Create it and add commands
         commands[mod_name] = \
             [_n[3:] for _n in dir(_p) if _n.startswith("do_")]
-        parsers[mod_name] = getattr(_p, 'init_parser')
+        parsers_inits[mod_name] = getattr(_p, 'init_parser')
+        parsers[mod_name] = {}
         helps[mod_name] = getattr(_p, 'command_help')
 
 
 def execute_command(args, command):
     # Validate the commands
     # check commands
+    if command not in commands:
+        
+        logger_cli.info("\n# Please, type a command listed above")
+        return 1
     if not hasattr(args, 'type') or not args.type:
+        parsers[command].print_help()
         logger_cli.info("\n# Please, type a command listed above")
         return 1
     _type = args.type.replace("-", "_") if "-" in args.type else args.type
-    if command not in commands:
-        logger_cli.info("\n# Please, type a command listed above")
-        return 1
-    elif _type not in commands[command]:
+    if _type not in commands[command]:
         # check type
         logger_cli.info(
             "\n# Please, select '{}' command type listed above".format(
@@ -79,7 +83,7 @@
 
 def cli_command(_title, _name):
     my_parser = MyParser(_title)
-    parsers[_name](my_parser)
+    parsers[_name] = parsers_inits[_name](my_parser)
 
     # parse arguments
     try:
diff --git a/cfg_checker/common/salt_utils.py b/cfg_checker/common/salt_utils.py
index dd6fbec..b3f5cae 100644
--- a/cfg_checker/common/salt_utils.py
+++ b/cfg_checker/common/salt_utils.py
@@ -242,7 +242,7 @@
             _payload['arg'] = param
         if kwarg:
             _payload['kwarg'] = kwarg
-
+        logger_cli.debug("SaltRequest: POST '{}'".format(_payload))
         _response = self.salt_request('post', [_payload])
         if isinstance(_response, list):
             return _response[0]
diff --git a/cfg_checker/nodes.py b/cfg_checker/nodes.py
index 13ab3e7..e028be2 100644
--- a/cfg_checker/nodes.py
+++ b/cfg_checker/nodes.py
@@ -70,7 +70,7 @@
             _valid, _invalid = utils.get_nodes_list(skip_list_file)
             logger_cli.info(
                 "\n# WARNING: Detected invalid entries "
-                "in nodes skip list:\n".format(
+                "in nodes skip list: {}\n".format(
                     "\n".join(_invalid)
                 )
             )