Exemple #1
0
        static void Main(string[] args)
        {
            EditorManager manager = new EditorManager();
            StringBuilder contentb = new StringBuilder();
            string line;
            while((line = Console.In.ReadLine()) != null)
            {
                contentb.AppendLine(line);
            }
            string content = contentb.ToString();

            if (args.Length > 0 && (args[0].Equals("help", StringComparison.CurrentCultureIgnoreCase) || args[0].Equals("/?", StringComparison.CurrentCultureIgnoreCase)))
            {
                Console.WriteLine(manager.Help(args));
                Console.ReadLine();
            }
            else
            {
                if (args.Length == 0)
                {
                    Console.WriteLine(manager.Help(args));
                    Console.WriteLine("Awaiting command");
                    args = manager.GetArgumentsFromString(Console.ReadLine());
                }
                manager.GetClipEditor(args[0]);
                manager.ClipEditor.EditorResponse += HandleResponseFromClippy;
                manager.ClipEditor.PersistentEditorResponse += HandleResponseFromClippy;

                SetParameters(manager, args);

                if (!manager.ClipEditor.HasAllParameters)
                {
                    Console.WriteLine("Y O U   M U S T   P A S S   A L L   R E Q U I R E D   P A R A M E T E R S");
                    Console.WriteLine(manager.ClipEditor.LongDescription);
                    return;
                }

                manager.ClipEditor.SourceData = content;
                manager.ClipEditor.Edit();
                content = manager.ClipEditor.SourceData;
                manager.ClipEditor.EditorResponse -= HandleResponseFromClippy;
                manager.ClipEditor.PersistentEditorResponse -= HandleResponseFromClippy;

            }

            Console.WriteLine(content);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            EditorManager manager = new EditorManager();
            if (args.Length > 0 && (args[0].Equals("help", StringComparison.CurrentCultureIgnoreCase) || args[0].Equals("/?", StringComparison.CurrentCultureIgnoreCase)))
            {
                Console.WriteLine(manager.Help(args));
                Console.ReadLine();
            }
            else if(args.Length > 0 &&
                    (args[0].Equals("--udfeditor", StringComparison.CurrentCultureIgnoreCase)
                     || args[0].Equals("--udf", StringComparison.CurrentCultureIgnoreCase)))
            {
                UdfEditor editorForm = new UdfEditor();
                editorForm.ShowDialog();
            }
            else
            {
                if (args.Length == 0)
                {
                    Console.WriteLine(manager.Help(args));
                    Console.WriteLine("Awaiting command");
                    args = manager.GetArgumentsFromString(Console.ReadLine());
                }
                manager.GetClipEditor(args[0]);
                manager.ClipEditor.EditorResponse += HandleResponseFromClippy;
                manager.ClipEditor.PersistentEditorResponse += HandleResponseFromClippy;

                SetParameters(manager, args);

                // if you've supplied at least one parameter, then set the rest, otherwise prompt
                if(args.Length > 1)
                {
                    foreach (Parameter parmWithDefault in (from Parameter p in manager.ClipEditor.ParameterList
                                                           where !p.IsValued && p.DefaultValue != null
                                                           select p))
                    {
                        parmWithDefault.Value = parmWithDefault.DefaultValue;
                    }
                }

                while (!manager.ClipEditor.HasAllParameters)
                {
                    Parameter nextOne = manager.ClipEditor.GetNextParameter();
                    Console.WriteLine(String.Concat(nextOne.ParameterName, " [",nextOne.Expecting,"]:"));

                    try
                    {
                        manager.ClipEditor.SetNextParameter(Console.ReadLine());
                    }
                    catch (InvalidParameterException ipe)
                    {
                        Console.WriteLine(ipe.ParameterMessage);
                        continue;
                    }
                }
                manager.ClipEditor.GetClipboardContent();
                manager.ClipEditor.Edit();
                manager.ClipEditor.SetClipboardContent();
                manager.ClipEditor.EditorResponse -= HandleResponseFromClippy;
                manager.ClipEditor.PersistentEditorResponse -= HandleResponseFromClippy;

                SaveThisCommand(args[0], manager.ClipEditor);
            }
        }
Exemple #3
0
 private static void SetParameters(EditorManager manager, string[] args)
 {
     while (true)
     {
         try
         {
             manager.ClipEditor.SetParameters(args);
             break;
         }
         catch (ClippyLib.InvalidParameterException pe)
         {
             Console.WriteLine("Error: " + pe.ParameterMessage);
             Console.WriteLine("Press enter to continue, results are not guaranteed\r\n");
             Console.ReadLine();
             break;
         }
         catch (ClippyLib.UndefinedFunctionException udfe)
         {
             manager.ClipEditor.EditorResponse -= HandleResponseFromClippy;
             Console.WriteLine(udfe.FunctionMessage);
             Console.WriteLine(manager.Help(args));
             Console.WriteLine("Awaiting command");
             args = manager.GetArgumentsFromString(Console.ReadLine());
             manager.GetClipEditor(args[0]);
             manager.ClipEditor.EditorResponse += new EventHandler<EditorResponseEventArgs>(HandleResponseFromClippy);
         }
     }
 }