Beispiel #1
0
        static void GenerateDefaultConfig(string configName, string mode)
        {
            if (string.IsNullOrEmpty(configName))
            {
                configName = _configFilePath;
            }

            if (!configName.EndsWith(".json"))
            {
                configName += ".json";
            }

            string templateFile = "config-" + ((mode == "cs") ? "csharp" : (mode == "ts") ? "typescript" : throw new UnknownParameterException("Wrong mode: " + mode)) + ".json";

            string content = ResourceFiles.GetResourceAsString("Resources", templateFile);

            File.WriteAllText(configName, content);
            Console.WriteLine($"Config {configName} successfully created");
        }
Beispiel #2
0
        static bool ReadArgs(string[] args)
        {
            foreach (var arg in args)
            {
                if (arg.Contains("--config:"))
                {
                    _configFilePath = arg.Substring("--config:".Length);
                }
                else if (arg.Contains("--create:"))
                {
                    var configNameWithMode = arg.Substring("--create:".Length);
                    var configName         = configNameWithMode.Substring(3);
                    var mode = configNameWithMode.Remove(2);
                    GenerateDefaultConfig(configName, mode);
                    return(false);
                }
                else if (arg.Contains("--output:"))
                {
                    _outputPath = arg.Substring("--output:".Length);
                    if (string.IsNullOrEmpty(_outputPath))
                    {
                        _outputPath = Directory.GetCurrentDirectory();
                    }
                }
                else if (arg == "-h" || arg == "--help")
                {
                    var help = ResourceFiles.GetResourceAsString("Resources", "help.txt");
                    Console.WriteLine(help);
                    return(false);
                }
                else
                {
                    throw new UnknownParameterException(string.Format("Unknown parameter {0}\nUse: aistdoc -h to read information about existing commands", arg));
                }
            }

            return(true);
        }
Beispiel #3
0
        public int Run()
        {
            var configName = FileName;

            if (!configName.EndsWith(".json"))
            {
                configName += ".json";
            }

            string templateFile = "config-" + ((Mode == "cs") ? "csharp"
                                                              : (Mode == "ts")
                                                                      ? "typescript"
                                                                      : (Mode == "git")
                                                                            ? "git"
                                                                            : throw new UnknownParameterException("Wrong mode: " + Mode)) + ".json";

            string content = ResourceFiles.GetResourceAsString("Resources", templateFile);

            File.WriteAllText(configName, content);
            Console.WriteLine($"Config {configName} successfully created");

            return(0);
        }