Exemple #1
0
        public void Execute(string[] arguments)
        {
            if (arguments.Length < 1)
            {
                return;
            }
            var filename = getFileName(arguments[0]);

            if (filename == null)
            {
                return;
            }
            var extension = getExtension(arguments[0]);
            var path      = getPath(arguments);

            if (path == null)
            {
                return;
            }
            var file = Path.Combine(
                path,
                filename);

            if (extension != null)
            {
                file += extension;
            }
            if (File.Exists(file))
            {
                return;
            }
            PathExtensions.CreateDirectories(file);
            var template = new ScriptLocator(_token, Environment.CurrentDirectory).GetTemplateFor(extension);
            var content  = "";

            if (template != null)
            {
                File.Copy(template, file);
            }
            else
            {
                var templates = new ScriptLocator(_token, Environment.CurrentDirectory).GetTemplates().ToArray();
                if (templates.Length == 0)
                {
                    File.WriteAllText(file, content);
                    if (Environment.OSVersion.Platform == PlatformID.Unix ||
                        Environment.OSVersion.Platform == PlatformID.MacOSX)
                    {
                        run("chmod", "+x \"" + file + "\"");
                    }
                }
                else
                {
                    File.WriteAllText(file, "");
                    File.Copy(templates[0], file);
                }
            }
            _dispatch("command|editor goto \"" + file + "|0|0\"");
        }
Exemple #2
0
        public void Execute(string[] arguments)
        {
            if (arguments.Length != 1)
            {
                return;
            }
            var file = Path.GetFullPath(arguments[0]);

            PathExtensions.CreateDirectories(file);
            File.WriteAllText(file, "");
            _dispatch("command|editor goto \"" + file + "|0|0\"");
        }
        private void newRScript(string[] args)
        {
            var language = getLanguage(args[2]);

            if (language == null)
            {
                return;
            }
            var filename = getFileName(args[3]);

            if (filename == null)
            {
                return;
            }
            var extension   = getExtension(args[3]);
            var createLocal = args.Length == 5 && args[4] == "-l";
            var path        = getLanguagePath(createLocal, language, "rscripts");

            if (path == null)
            {
                return;
            }
            var file = Path.Combine(
                path,
                filename);

            if (extension != null)
            {
                file += extension;
            }
            if (File.Exists(file))
            {
                return;
            }
            PathExtensions.CreateDirectories(file);
            var template = new ReactiveScriptLocator(_token, Environment.CurrentDirectory).GetTemplateFor(extension);
            var content  = "";

            if (template != null)
            {
                File.Copy(template, file);
            }
            else
            {
                var templates = new ReactiveScriptLocator(_token, Environment.CurrentDirectory).GetTemplates().ToArray();
                if (templates.Length == 0)
                {
                    File.WriteAllText(file, content);
                    if (Environment.OSVersion.Platform == PlatformID.Unix ||
                        Environment.OSVersion.Platform == PlatformID.MacOSX)
                    {
                        run("chmod", "+x \"" + file + "\"");
                    }
                }
                else
                {
                    File.WriteAllText(file, "");
                    File.Copy(templates[0], file);
                }
            }

            _dispatch("command|editor goto \"" + file + "|0|0\"");
        }