private static void ParseCategoriesRecursive(JToken jobject)
        {
            if (null == jobject?[Constants.Categories])
            {
                return;
            }

            var keys = JObject.Parse(jobject[Constants.Categories].ToString()).Properties().Select(p => p.Name).ToList();

            foreach (var key in keys)
            {
                var temp     = jobject[Constants.Categories][key];
                var category = new AzureXplatCliViewModel
                {
                    Name        = (string)temp[Constants.Name],
                    Description = (string)temp[Constants.Description],
                    Usage       = (string)temp[Constants.Usage],
                    Commands    = temp[Constants.Commands].ToObject <List <Command> >()
                };

                Save(category.Name, category);
                var categoriesCount = JObject.Parse(temp[Constants.Categories].ToString()).Properties().Select(p => p.Name).ToList().Count;

                if (null != temp[Constants.Categories] && 0 != categoriesCount)
                {
                    Directory.CreateDirectory(category.Name);
                    Directory.SetCurrentDirectory(Path.Combine(Directory.GetCurrentDirectory(), category.Name));
                    ParseCategoriesRecursive(temp);
                    Directory.SetCurrentDirectory(new DirectoryInfo(Directory.GetCurrentDirectory()).Parent.FullName);
                }
            }
        }
        private static void SplitJsonToYamls(string mode, string azureFilePath, string pluginsFilePath, string destRoot)
        {
            if (string.IsNullOrEmpty(mode) || !IsValidFile(azureFilePath) || !IsValidFile(pluginsFilePath))
            {
                return;
            }

            var modeName = Constants.ModeNameMapping[mode];
            var modePath = Path.Combine(destRoot, modeName);
            var vm       = new AzureXplatCliViewModel();

            using (var str = new StreamReader(azureFilePath))
            {
                var jobject = JObject.Parse(str.ReadToEnd());
                vm.Name        = (string)jobject[Constants.Name];
                vm.Description = (string)jobject[Constants.Description];
                vm.Usage       = (string)jobject[Constants.Usage];
            }

            // use plugins.arm/asm.json to set commands and categories to fullfill the filepath
            using (var str = new StreamReader(pluginsFilePath))
            {
                var jobject = JObject.Parse(str.ReadToEnd());
                vm.Commands = jobject[Constants.Commands].ToObject <List <Command> >();
                Directory.SetCurrentDirectory(destRoot);
                Save(modeName, vm);
                Directory.CreateDirectory(modePath);
                Directory.SetCurrentDirectory(modePath);
                if (null != jobject[Constants.Categories])
                {
                    ParseCategoriesRecursive(jobject);
                }
            }

            Directory.SetCurrentDirectory(modePath);
        }