コード例 #1
0
ファイル: App.cs プロジェクト: codemerx/CodemerxDecompile
        public static void Main(string[] args)
        {
            GeneratorProjectInfo generatorProjectInfo = CommandLineManager.Parse(args);
            CmdShell             shell = new CmdShell();

            shell.Run(generatorProjectInfo);
        }
コード例 #2
0
        public void TestBasic()
        {
            bool lExecuted = false;
            bool zExecuted = false;

            var clm = new CommandLineManager();

            clm.AddOption("L", "List out the operation.", (clmanager) => lExecuted = true);
            clm.AddOption("S,Save", "Save the operation.");
            clm.AddOption("Zebra", "Zero out the operation.", (clmanager) => zExecuted = true);

            clm.Execute(new[] { "-L", "Data", "-Zebra", "-Save" });


            Assert.IsTrue(clm.L);
            Assert.IsTrue(clm.IsMultipleLetterOptionFound("L"));
            Assert.IsFalse(clm.IsMultipleLetterOptionFound("Data"));
            Assert.IsTrue(clm.S);
            Assert.IsFalse(clm.D);
            Assert.IsTrue(lExecuted);

            Assert.IsTrue(clm.IsMultipleLetterOptionFound("Zebra"));

            Assert.IsFalse(clm.Z);
            Assert.IsTrue(zExecuted);
        }
コード例 #3
0
        public void TestData()
        {
            bool lExecuted = false;
            bool zExecuted = false;

            var clm = new CommandLineManager();

            clm.AddOptionRequiresData("L", "List out the operation.", (clmanager) => lExecuted = true);
            clm.AddOption("S,Save", "Save the operation.");
            clm.AddOption("Zebra", "Zero out the operation.", (clmanager) => zExecuted = true);

            clm.Execute(new[] { "-L", "Data", "-Zebra", "-Save", "Unknown" });


            Assert.IsTrue(clm.L);
            Assert.IsTrue(clm["L"].Equals("Data"));

            Assert.IsTrue(string.IsNullOrEmpty(clm["Z"]));
            Assert.IsTrue(clm.S);
            Assert.IsTrue(string.IsNullOrEmpty(clm["S"]));
            Assert.IsFalse(clm.D);
            Assert.IsTrue(string.IsNullOrEmpty(clm["D"]));
            Assert.IsTrue(lExecuted);
            Assert.IsFalse(clm.Z);
            Assert.IsTrue(zExecuted);
        }
コード例 #4
0
ファイル: App.xaml.cs プロジェクト: windygu/NETworkManager
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            // Parse the command line arguments and store them in the current configuration
            CommandLineManager.Parse();

            // If we have restart our application... wait until it has finished
            if (CommandLineManager.Current.RestartPid != 0)
            {
                Process[] processList = Process.GetProcesses();

                Process process = processList.FirstOrDefault(x => x.Id == CommandLineManager.Current.RestartPid);

                if (process != null)
                {
                    process.WaitForExit();
                }
            }

            // Detect the current configuration
            ConfigurationManager.Detect();

            // Get assembly informations
            AssemblyManager.Load();

            // Load application settings (profiles/sessions/clients are loaded when needed)
            SettingsManager.Load();

            // Load localization (requires settings to be loaded first)
            LocalizationManager.Load();

            if (CommandLineManager.Current.Help)
            {
                StartupUri = new Uri("/Views/Help/HelpCommandLineWindow.xaml", UriKind.Relative);
                return;
            }

            // Create mutex
            _mutex = new Mutex(true, "{" + Guid + "}");
            bool mutexIsAcquired = _mutex.WaitOne(TimeSpan.Zero, true);

            // Release mutex
            if (mutexIsAcquired)
            {
                _mutex.ReleaseMutex();
            }

            if (SettingsManager.Current.Window_MultipleInstances || mutexIsAcquired)
            {
                StartupUri = new Uri("MainWindow.xaml", UriKind.Relative);
            }
            else
            {
                // Bring the already running application into the foreground
                SingleInstanceHelper.PostMessage((IntPtr)SingleInstanceHelper.HWND_BROADCAST, SingleInstanceHelper.WM_SHOWME, IntPtr.Zero, IntPtr.Zero);

                _singleInstanceClose = true;
                Shutdown();
            }
        }
コード例 #5
0
        static void ProcessFile(CommandLineManager clm)
        {
            var file = clm["f"];

            Console.WriteLine($"Processing File {file}");

            Console.WriteLine(Environment.NewLine);
        }
コード例 #6
0
        static void Main(string[] args)
        {
            var info = "Take a data file and create templated SQL";

            var cml = new CommandLineManager();

            cml.DisplayProductAndVersion()  // Take the Product name and version from AssemblyInfo.cs
            .DisplayBeforeDescription((o) => Console.WriteLine($"{info}{Environment.NewLine}"))
            .DisplayDescriptionOnNoOperation()
            .AddOption("f", "Pathed data file.", ProcessFile)
            .Execute(new[] { "-f", "C:\\Temp\\abc.text" });
        }
コード例 #7
0
        public void TestDataDoubleLetter()
        {
            bool lExecuted = false;

            var clm = new CommandLineManager();

            clm.AddOptionRequiresData("LD", "List out the operation.", (clmanager) => lExecuted = true);

            clm.Execute(new[] { "-LD", "Data" });
            Assert.IsTrue(clm["LD"].Equals("Data"));
            Assert.IsTrue(lExecuted);
        }
コード例 #8
0
 public void TestBasicDescription()
 {
     CommandLineManager.Instantiation()
     .DisplayTitleAndVersion()
     .DisplayDescriptionOnNoOperation()
     .AddOption("M", "Migrate the directory")
     .AssociateWithSubOptions("D")
     .AddOptionRequiresData("D", "Directory To Migrate")
     .AddOption("L", "List the directory contents")
     .AssociateWithSubOptions("D")
     .Execute();
 }
コード例 #9
0
        static async Task Main(string[] args)
        {
            ShowWelcome();
            CommandLineManager.Parse(args);

            // await new BigBlueButtonFacade(
            //         new FileDownloader(),
            //         new VideoService(),
            //         new PresentationService(new VideoService()))
            //     .SetUrl(
            //         "https://bbb16.pau.edu.tr/playback/presentation/2.0/playback.html?meetingId=12c8395af12fab1af1d10342665ffd9329c241d4-1602053283330")
            //     .EnableMultiThread()
            //     .SetDriverType(WebDriverType.Chrome)
            //     .EnableDownloadWebcamVideo()
            //     .EnableDownloadDeskshareVideo()
            //     .EnableDownloadPresentation()
            //     .SetOutputFileName("BigBlueButtonVideo_1")
            //     .SetOutputDirectory("/Users/berkay.yalcin/Desktop/deneme")
            //     .SetTimeoutSeconds(60)
            //     .StartAsync();
        }
コード例 #10
0
        public void TestMultipleOptions()
        {
            string info = "Operations to be performed: ";

            CommandLineManager.Instantiation()
            .DisplayBeforeDescription((o) => Console.WriteLine($"{info}{Environment.NewLine}"))
            .DisplayProductAndVersion()
            .DisplayDescriptionOnNoOperation()
            .AddOption("Q", "Queue the App into named pipe remote command mode", clm => Console.WriteLine("Queue Mode"))
            .AddOption("U", "Upload a file to Azure", clm => Console.WriteLine("Uploading"))
            .AddValidation(clm => true)
            .AssociateWithSubOptions("F", "C", "B")
            .AddOptionRequiresData("F", "File name of the file.")
            .AddOptionRequiresData("C", "(Azure) Container to use or create in Azure.")
            .AddOptionRequiresData("B", "(Azure) Blob name to use. If none specified, the filename will be used.")
            .AddOption("D", "Download a file From Azure", clm => Console.WriteLine("Downloading"))
            .AddValidation(clm => true)
            .AssociateWithSubOptions("F", "C", "B")
            .AddOption("S", "Show credentials to be used.", clm => Console.WriteLine("Showing"))
            .Execute();
        }
コード例 #11
0
        public void Titling()
        {
            bool titleOp   = false;
            bool lExecuted = false;
            var  clm       = new CommandLineManager();

            clm.ReportTitle(cml => titleOp = true)
            .AddOptionRequiresData("LD", "List out the operation.", (clmanager) => lExecuted = true)
            .Execute();

            Assert.IsTrue(titleOp);
            Assert.IsFalse(lExecuted);

            // Reset for alternate test.
            titleOp = false;
            clm.Parse(new[] { "-LD", "Data" })
            .Execute();

            Assert.IsFalse(titleOp);
            Assert.IsTrue(lExecuted);
        }
コード例 #12
0
        public void TestValidation()
        {
            bool lExecuted = false;

            var clm = new CommandLineManager();

            clm.AddOptionRequiresData("L", "List out the operation.", (clmanager) => lExecuted = true);

            clm.AddValidation((manager) => false);

            clm.Execute(new[] { "-L", "Data" });

            Assert.IsFalse(lExecuted);

            // Change it to true. We can do this because the `LastOption` is still set.
            clm.AddValidation((manager) => true);

            clm.Execute(new[] { "-L", "Data" });


            Assert.IsTrue(lExecuted);
        }
コード例 #13
0
 public static void startIterative()
 {
     Debug.Log("Beginning iterative debug seed!");
     CommandLineManager.learnTest(convertLevelSet(), false, true, false);
 }
コード例 #14
0
 public void TitleDefault()
 {
     CommandLineManager.Instantiation()
     .DisplayTitleAndVersion()
     .Execute();
 }
コード例 #15
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            // Parse the command line arguments and store them in the current configuration
            CommandLineManager.Parse();

            // If we have restart our application... wait until it has finished
            if (CommandLineManager.Current.RestartPid != 0)
            {
                var processList = Process.GetProcesses();

                var process = processList.FirstOrDefault(x => x.Id == CommandLineManager.Current.RestartPid);

                process?.WaitForExit();
            }

            // Detect the current configuration
            ConfigurationManager.Detect();

            // Get assembly informations
            AssemblyManager.Load();

            // Load application settings (profiles/Profiles/clients are loaded when needed)
            try
            {
                // Update integrated settings %LocalAppData%\NETworkManager\NETworkManager_GUID (custom settings path)
                if (Settings.Default.UpgradeRequired)
                {
                    Settings.Default.Upgrade();
                    Settings.Default.UpgradeRequired = false;
                }

                SettingsManager.Load();

                // Update settings (Default --> %AppData%\NETworkManager\Settings)
                if (AssemblyManager.Current.Version > new Version(SettingsManager.Current.SettingsVersion))
                {
                    SettingsManager.Update(AssemblyManager.Current.Version, new Version(SettingsManager.Current.SettingsVersion));
                }
            }
            catch (InvalidOperationException)
            {
                SettingsManager.InitDefault();
                ConfigurationManager.Current.ShowSettingsResetNoteOnStartup = true;
            }

            // Load localization (requires settings to be loaded first)
            LocalizationManager.Load();

            NETworkManager.Resources.Localization.Strings.Culture = LocalizationManager.Culture;

            if (CommandLineManager.Current.Help)
            {
                StartupUri = new Uri("/Views/CommandLineHelpWindow.xaml", UriKind.Relative);
                return;
            }

            // Create mutex
            _mutex = new Mutex(true, "{" + Guid + "}");
            var mutexIsAcquired = _mutex.WaitOne(TimeSpan.Zero, true);

            // Release mutex
            if (mutexIsAcquired)
            {
                _mutex.ReleaseMutex();
            }

            if (SettingsManager.Current.Window_MultipleInstances || mutexIsAcquired)
            {
                StartupUri = new Uri("MainWindow.xaml", UriKind.Relative);
            }
            else
            {
                // Bring the already running application into the foreground
                SingleInstance.PostMessage((IntPtr)SingleInstance.HWND_BROADCAST, SingleInstance.WM_SHOWME, IntPtr.Zero, IntPtr.Zero);

                _singleInstanceClose = true;
                Shutdown();
            }
        }
コード例 #16
0
 public static void startRandom()
 {
     Debug.Log("Beginning random debug seed!");
     CommandLineManager.learnTest(convertLevelSet(), true, false, false);
 }
コード例 #17
0
ファイル: App.xaml.cs プロジェクト: chatay/NETworkManager
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            // Parse the command line arguments and store them in the current configuration
            CommandLineManager.Parse();

            // If we have restart our application... wait until it has finished
            if (CommandLineManager.Current.RestartPid != 0)
            {
                var processList = Process.GetProcesses();

                var process = processList.FirstOrDefault(x => x.Id == CommandLineManager.Current.RestartPid);

                process?.WaitForExit();
            }

            // Detect the current configuration
            ConfigurationManager.Detect();

            // Get assembly informations
            AssemblyManager.Load();

            bool profileUpdateRequired = false;

            // Load application settings
            try
            {
                // Update integrated settings %LocalAppData%\NETworkManager\NETworkManager_GUID (custom settings path)
                if (Settings.Default.UpgradeRequired)
                {
                    Settings.Default.Upgrade();
                    Settings.Default.UpgradeRequired = false;
                }

                SettingsManager.Load();

                // Update settings (Default --> %AppData%\NETworkManager\Settings)
                Version assemblyVersion = AssemblyManager.Current.Version;
                Version settingsVersion = new Version(SettingsManager.Current.SettingsVersion);

                if (AssemblyManager.Current.Version > settingsVersion)
                {
                    SettingsManager.Update(AssemblyManager.Current.Version, settingsVersion);
                }
            }
            catch (InvalidOperationException)
            {
                SettingsManager.InitDefault();

                profileUpdateRequired = true; // Because we don't know if a profile update is required

                ConfigurationManager.Current.ShowSettingsResetNoteOnStartup = true;
            }

            // Upgrade profile if version has changed or settings have been reset (mthis happens mostly, because the version has changed and values are wrong)
            if (profileUpdateRequired)
            {
                try
                {
                    ProfileManager.Upgrade();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Failed to update profiles...\n\n" + ex.Message, "Profile Manager - Update Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }

            // Load localization (requires settings to be loaded first)
            LocalizationManager.Load();

            NETworkManager.Resources.Localization.Strings.Culture = LocalizationManager.Culture;

            if (CommandLineManager.Current.Help)
            {
                StartupUri = new Uri("/Views/CommandLineHelpWindow.xaml", UriKind.Relative);
                return;
            }

            // Create mutex
            _mutex = new Mutex(true, "{" + GUID + "}");
            var mutexIsAcquired = _mutex.WaitOne(TimeSpan.Zero, true);

            // Release mutex
            if (mutexIsAcquired)
            {
                _mutex.ReleaseMutex();
            }

            if (SettingsManager.Current.Window_MultipleInstances || mutexIsAcquired)
            {
                if (SettingsManager.Current.General_BackgroundJobInterval != 0)
                {
                    _dispatcherTimer = new DispatcherTimer
                    {
                        Interval = TimeSpan.FromMinutes(SettingsManager.Current.General_BackgroundJobInterval)
                    };

                    _dispatcherTimer.Tick += DispatcherTimer_Tick;

                    _dispatcherTimer.Start();
                }

                StartupUri = new Uri("MainWindow.xaml", UriKind.Relative);
            }
            else
            {
                // Bring the already running application into the foreground
                SingleInstance.PostMessage((IntPtr)SingleInstance.HWND_BROADCAST, SingleInstance.WM_SHOWME, IntPtr.Zero, IntPtr.Zero);

                _singleInstanceClose = true;
                Shutdown();
            }
        }
コード例 #18
0
        private void btnCreateSite_Click(object sender, RoutedEventArgs e)
        {
            ErrorMessage.Visibility = Visibility.Hidden;
            try
            {
                if (String.IsNullOrEmpty(this.txtSiteName.Text))
                {
                    throw new Exception("Site Name must Not be empty");
                }

                if (String.IsNullOrEmpty(this.txtWebLocation.Text))
                {
                    throw new Exception("Location must Not be empty");
                }

                if (String.IsNullOrEmpty(this.txtPort.Text) ||
                    ((Int32.Parse(this.txtPort.Text) > 65535)))
                {
                    throw new Exception("Port number is not valid it should be in range 0-65535");
                }

                List <string> commandStringList = new List <string>();

                CommandParser cmdParser = new CommandParser(Environment.CurrentDirectory + "\\commands.json");

                Dictionary <string, string[]> CommandsForExecution = new Dictionary <string, string[]>();
                CommandsForExecution.Add("NPMInit", new string[] { });
                CommandsForExecution.Add("NPMInstallPackage", new string[] { "--save express" });
                CommandsForExecution.Add("CmdCreateDirectory", new string[] { "public" });

                foreach (var pair in CommandsForExecution)
                {
                    var com = cmdParser.GetCommand(pair.Key).Generate(pair.Value);
                    commandStringList.Add(com);
                }

                System.IO.Directory.CreateDirectory(System.IO.Path.Combine(this.txtWebLocation.Text, this.txtSiteName.Text));
                CommandLineManager mgr = new CommandLineManager(System.IO.Path.Combine(this.txtWebLocation.Text, this.txtSiteName.Text));
                mgr.Commands = commandStringList;
                mgr.Run();

                //Create QuickStart Scripts
                var moduleDir = System.IO.Path.Combine(this.txtWebLocation.Text,
                                                       this.txtSiteName.Text,
                                                       "nsm-server-config");
                Directory.CreateDirectory(moduleDir);

                var packConfigContent = @"{
                    ""name"":""nsm-server-config"",
                    ""description"":""Server Configuration NSM"",
                    ""version"":""1.0.0"",
                    ""main"":""index.js""
                 }";

                System.IO.File.WriteAllText(System.IO.Path.Combine(moduleDir, "index.js"),
                                            String.Format("module.exports.portNumber = {0}", this.txtPort.Text));

                System.IO.File.WriteAllText(System.IO.Path.Combine(moduleDir, "package.json"), packConfigContent);


                if (this.cmbWebServer.Text.ToLower() == "express")
                {
                    File.Copy(System.IO.Path.Combine(Environment.CurrentDirectory, "QuickStartScripts\\Express.js"),
                              System.IO.Path.Combine(this.txtWebLocation.Text,
                                                     this.txtSiteName.Text,
                                                     "server.js"));
                }

                App.siteManager.CreateSite(new Site
                {
                    SiteId       = Guid.NewGuid().ToString(),
                    SiteName     = this.txtSiteName.Text,
                    SiteLocation = txtWebLocation.Text,
                    SitePort     = Int32.Parse(txtPort.Text),
                    Extensions   = new List <string>()
                });

                App.siteManager.Save();

                ((MainWindow)System.Windows.Application.Current.MainWindow).NavigationFrame.Navigate(new Home());

                OnSitesUpdated(new EventArgs());
            }
            catch (Exception ex)
            {
                ErrorMessage.Visibility = Visibility.Visible;
                ErrorMessage.Content    = ex.Message;
            }
        }
コード例 #19
0
ファイル: Spock.cs プロジェクト: erraticmotion/spock
        /// <summary>
        /// Defines the entry point of the application.
        /// </summary>
        /// <param name="args">The arguments.</param>
        public static void Main(string[] args)
        {
            var options = CommandLineManager.GetCommandLineArguments <CommandLineArgs>(args);

            if (!options.IsValid || !options.SearchValid())
            {
                Console.WriteLine(options.Usage);
#if IN_DEV
                Console.WriteLine("Press any key to exit");
                Console.ReadLine();
#endif
                Environment.Exit(1);
            }

            if (!string.IsNullOrEmpty(options.I18N))
            {
                var lang = Internationalization.Vocabularies.Find(options.I18N);
                if (lang == null)
                {
                    Console.WriteLine("Language not supported");
                }
                else
                {
                    Console.WriteLine(lang);
                }
#if IN_DEV
                Console.WriteLine("Press any key to exit");
                Console.ReadLine();
#endif
                Environment.Exit(0);
            }

            if (options.IsIntrospectionSpecified())
            {
                Console.WriteLine("Introspection target {0}", options.IntrospectionTarget);
                Assembly assembly = null;
                try
                {
                    assembly = Assembly.LoadFile(options.IntrospectionTarget);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Introspection target threw an error.");
                    Console.WriteLine(ex.Message);
                }

                if (assembly != null)
                {
                    var engine = new IntrospectionEngine(assembly);
                    var fi     = new FileInfo(Assembly.GetExecutingAssembly().Location);
                    var path   = $"{fi.DirectoryName}\\Welcome.aml";
                    try
                    {
                        if (File.Exists(path))
                        {
                            File.Delete(path);
                        }

                        var welcome = engine.GetWelcomeTopic(new Guid("97f76524-0712-4f9d-85cc-f0f66bad60da"), 1);
                        using (var outputFile = new StreamWriter(path))
                        {
                            foreach (var line in welcome)
                            {
                                outputFile.WriteLine(line);
                            }
                        }

                        Console.WriteLine("Welcome.aml written to '{0}'", path);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Deleting the file {0} resulted in an error.", path);
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            else if (options.IsFileSpecified())
            {
                try
                {
                    var gherkin = Test.Tools.Gherkin.Lexer.For(options.Source().FullName).Parse();
                    var spock   = Test.Tools.Spock.Lexer.For(options).Parse(gherkin);
                    using (var outputFile = new StreamWriter(spock.FixtureInvariants.FilePath))
                    {
                        foreach (var line in spock.Spock())
                        {
                            outputFile.WriteLine(line);
                        }
                    }

                    Console.WriteLine(" '{0}' file generated", spock.FixtureInvariants.FilePath);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.WriteLine(Environment.NewLine);
                    Console.WriteLine(ex);
#if IN_DEV
                    Console.WriteLine("Press any key to exit");
                    Console.ReadLine();
#endif
                    Environment.Exit(1);
                }
            }
            else
            {
                var generated      = 0;
                var noScenarios    = 0;
                var invalidGherkin = 0;
                var gherkinUnknown = 0;
                var notCaught      = 0;

                // search a complete directory for .feature files.
                foreach (var fi in options.DirectoryInfo().GetFiles("*.feature"))
                {
                    try
                    {
                        var gherkin = Test.Tools.Gherkin.Lexer.For(fi.FullName).Parse();
                        var spock   = Test.Tools.Spock.Lexer.For(options).Parse(gherkin);
                        using (var outputFile = new StreamWriter(spock.FixtureInvariants.FilePath))
                        {
                            foreach (var line in spock.Spock())
                            {
                                outputFile.WriteLine(line);
                            }
                        }

                        generated++;
                    }
                    catch (Test.Tools.Gherkin.GherkinException ex)
                    {
                        switch (ex.Reason)
                        {
                        case Test.Tools.Gherkin.GherkinExceptionType.NoScenariosInFeature:
                            noScenarios++;
                            break;

                        case Test.Tools.Gherkin.GherkinExceptionType.InvalidGherkin:
                            invalidGherkin++;
                            break;

                        default:
                            Console.WriteLine(" Gherkin Unknown: '{0}' file", fi.FullName);
                            Console.WriteLine(ex.Message);
                            gherkinUnknown++;
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(" Error generating from '{0}' file", fi.FullName);
                        Console.WriteLine(ex.Message);
                        notCaught++;
                    }
                }

                Console.WriteLine("{0} file(s) generated.", generated);
                Console.WriteLine("{0} file(s) with no scenarios.", noScenarios);
                Console.WriteLine("{0} file(s) invalid Gherkin.", invalidGherkin);
                Console.WriteLine("{0} file(s) unknown Gherkin.", gherkinUnknown);
                Console.WriteLine("{0} file(s) not caught.", notCaught);
            }
#if IN_DEV
            Console.WriteLine("Press any key to exit");
            Console.ReadLine();
#endif
            Environment.Exit(0);
        }
コード例 #20
0
 public void PrintError()
 {
     CommandLineManager.PrintHelpText();
 }
コード例 #21
0
ファイル: Program.cs プロジェクト: AkariAkaori/KaoriStudio
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                ShowHelp(Console.Error);
                return;
            }

            var cmd = new CommandLineManager(new UnixCommandLineParser());
            cmd.SetupDefaultParsers();
            cmd.Setup(typeof(Program));
            cmd.ParseArguments(args);
        }