Example #1
0
        private static object RunInitAndReturnExitCode(InitOptions opts)
        {
            Telemetry.Current.TrackEvent("InitCommand");
            string configFile = opts.ConfigFile;

            if (configFile.IsEmpty())
            {
                configFile = "configuration.json";
            }
            Telemetry.Current.TrackEvent("InitCommand");
            Trace.WriteLine(String.Format("ConfigFile: {0}", configFile), "[Info]");
            if (File.Exists(configFile))
            {
                Trace.WriteLine("Deleting old configuration.json reference file", "[Info]");
                File.Delete(configFile);
            }
            if (!File.Exists(configFile))
            {
                Trace.WriteLine(string.Format("Populating config with {0}", opts.Options.ToString()), "[Info]");
                EngineConfiguration config;
                switch (opts.Options)
                {
                case OptionsMode.Full:
                    config = EngineConfiguration.GetDefault();
                    break;

                case OptionsMode.WorkItemTracking:
                    config = EngineConfiguration.GetWorkItemMigration();
                    break;

                default:
                    config = EngineConfiguration.GetDefault();
                    break;
                }

                string json = JsonConvert.SerializeObject(config, Formatting.Indented,
                                                          new FieldMapConfigJsonConverter(),
                                                          new ProcessorConfigJsonConverter());
                StreamWriter sw = new StreamWriter(configFile);
                sw.WriteLine(json);
                sw.Close();
                Trace.WriteLine("New configuration.json file has been created", "[Info]");
            }
            return(0);
        }