var util = require('util');
var exec = require('child_process').exec,
    child;

var result = {};
child = exec('azure config mode asm', {maxBuffer: 1000*1024}, function (error, stdout, stderr) {
	console.log(stdout);
	child = exec('azure help --json', {maxBuffer: 1000*1024}, function (error, stdout, stderr) {
  	var data = JSON.parse(stdout);
    parse(data);
    if (error) {
      console.log('exec error: ' + error);
    }
    child = exec('azure config mode arm', {maxBuffer: 1000*1024}, function (error, stdout, stderr) {
    	console.log(stdout);
    	child = exec('azure help --json', {maxBuffer: 1000*1024}, function (error, stdout, stderr) {
    		var data = JSON.parse(stdout);
		    parse(data);
		    if (error) {
		      console.log('exec error: ' + error);
		    }
		    var cmds = Object.keys(result);
		    console.log(util.inspect(cmds, {depth: null}));
		    console.log("The total number of commands for xplat-cli in asm and arm mode is: " + cmds.length);
    	});
    });
  });
});


function parse(cmdObj) {
	if (cmdObj) {
		Object.keys(cmdObj).forEach(function(key) {
			if (key === 'commands') {
				cmdObj[key].forEach(function(element) {
					result[element.name] = element.name;
				});
			}
			else {
				parse(cmdObj[key]);
			}
	  });
	}
}
@@ -189,17 +189,18 @@
 derr) %7B%0A
-%09
+  
 console.
@@ -212,17 +212,18 @@
 tdout);%0A
-%09
+  
 child = 
@@ -309,17 +309,18 @@
 rr) %7B%0A  
-%09
+  
 var data
@@ -530,17 +530,18 @@
 ) %7B%0A    
-%09
+  
 console.
@@ -557,17 +557,18 @@
 t);%0A    
-%09
+  
 child = 
@@ -656,18 +656,20 @@
 ) %7B%0A    
-%09%09
+    
 var data
@@ -687,26 +687,28 @@
 se(stdout);%0A
-%09%09
+    
     parse(da
@@ -712,22 +712,24 @@
 (data);%0A
-%09%09
+  
     
+  
 if (erro
@@ -733,18 +733,20 @@
 rror) %7B%0A
-%09%09
+    
       co
@@ -784,18 +784,22 @@
 r);%0A
-%09%09
+    
     %7D%0A
-%09%09
+    
     
@@ -830,18 +830,20 @@
 esult);%0A
-%09%09
+    
     cons
@@ -886,18 +886,20 @@
 ull%7D));%0A
-%09%09
+    
     cons
@@ -996,17 +996,18 @@
 h);%0A    
-%09
+  
 %7D);%0A    
@@ -1021,17 +1021,16 @@
 );%0A%7D);%0A%0A
-%0A
 function
@@ -1046,17 +1046,18 @@
 dObj) %7B%0A
-%09
+  
 if (cmdO
@@ -1062,18 +1062,20 @@
 dObj) %7B%0A
-%09%09
+    
 Object.k
@@ -1110,19 +1110,22 @@
 (key) %7B%0A
-%09%09%09
+      
 if (key 
@@ -1142,20 +1142,24 @@
 nds') %7B%0A
-%09%09%09%09
+        
 cmdObj%5Bk
@@ -1194,13 +1194,18 @@
 ) %7B%0A
-%09%09%09%09%09
+          
 resu
@@ -1241,35 +1241,49 @@
 me;%0A
-%09%09%09%09%7D);%0A%09%09%09%7D%0A%09%09%09else %7B%0A%09%09%09%09
+        %7D);%0A      %7D%0A      else %7B%0A        
 pars
@@ -1302,20 +1302,25 @@
 %5D);%0A
-%09%09%09%7D%0A%09
+      %7D%0A  
   %7D);%0A
-%09
+  
 %7D%0A%7D

Convert tabs to spaces in indentation