コード例 #1
0
        private string getPath(string[] arguments)
        {
            var isGlobal = arguments.Contains("--global") || arguments.Contains("-g");
            var locator  = new ReactiveScriptLocator(_token, Environment.CurrentDirectory);

            if (isGlobal)
            {
                return(locator.GetGlobalPath());
            }
            else
            {
                return(locator.GetLocalPath());
            }
        }
コード例 #2
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 file = Path.Combine(
                getPath(arguments),
                filename);
            if (extension != null)
                file += extension;
            if (File.Exists(file))
                return;
            Console.WriteLine("Creating " + file);
            PathExtensions.CreateDirectories(file);
            var template = new ReactiveScriptLocator().GetTemplateFor(extension);
            var content = "";
            if (template != null)
                File.Copy(template, file);
            else
            {
                var templates = new ReactiveScriptLocator().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("editor goto \"" + file + "|0|0\"");
        }
コード例 #3
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\"");
        }
コード例 #4
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;
            }
            Console.WriteLine("Creating " + file);
            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\"");
        }