Ejemplo n.º 1
0
        private static void Main(string[] args)
        {
            var shell  = new ShellShellExecutor();
            var runCmd = new RunCommand(CommandNames.Run);

            shell.ConfigureCommand(runCmd);

            shell.ConfigureCommand(new SetConfigValueCommand(CommandNames.Set));
            shell.ConfigureCommand(new GetConfigValueCommand(CommandNames.Get));
            shell.ConfigureCommand(new RemoveConfigValueCommand(CommandNames.Remove));
            shell.ConfigureCommand(new GetSystemProxyCommand(CommandNames.SystemProxy));
            shell.ConfigureCommand(new AddToPathCommand(BasicCommandNames.AddToPathCommandName));
            shell.ConfigureCommand(new GetVersionCommand(CommandNames.Version));
            shell.ConfigureCommand(new GetLicenseCommand(CommandNames.License));

            shell.UseDefaultCommand = true;
            shell.DefaultCommand    = runCmd;

            try
            {
                shell.SetArguments(args);
                shell.Execute();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Ejemplo n.º 2
0
        private void Execute(ShellShellExecutor executor)
        {
            // Obtain the 'Proxy' of the  Default browser.
            string proxy  = ProxyHelper.GetSystemProxy();
            string proxyS = ProxyHelper.GetSystemHttpsProxy();

            // Print the Proxy Url to the console.
            if (!string.IsNullOrEmpty(proxy))
            {
                Console.WriteLine("Http Proxy: {0}", proxy);
            }
            else
            {
                Console.WriteLine("Http Proxy is null; no Http proxy will be used");
            }

            if (!string.IsNullOrEmpty(proxy))
            {
                Console.WriteLine("Https Proxy: {0}", proxyS);
            }
            else
            {
                Console.WriteLine("Https Proxy is null; no Https proxy will be used");
            }
        }
Ejemplo n.º 3
0
        private void Execute(ShellShellExecutor executor)
        {
            ApplicationSettings config = ApplicationSettings.LoadSettings();
            string key     = executor.GetParameterAsString(ParameterNames.Key);
            string value   = executor.GetParameterAsString(ParameterNames.Value);
            bool   asEnVar = GetSwitchValue(SwitchesNames.AsEnvironmentVar);

            if (asEnVar)
            {
                if (config.EnvironmentVariables.ContainsKey(key))
                {
                    config.EnvironmentVariables[key] = value;
                }
                else
                {
                    config.EnvironmentVariables.Add(key, value);
                }
            }
            else
            {
                if (config.Settings.ContainsKey(key))
                {
                    config.Settings[key] = value;
                }
                else
                {
                    config.Settings.Add(key, value);
                }
            }

            config.SaveSettings();
            Console.WriteLine($"Setting {executor.GetParameterAsString(ParameterNames.Key)} saved!");
        }
Ejemplo n.º 4
0
 private void Execute(ShellShellExecutor executor)
 {
     Console.WriteLine("Groxy:");
     Console.WriteLine("The MIT License (MIT)\r\n\r\nCopyright (c) 2018 Christian Kovacs\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.");
     Console.WriteLine();
     Console.WriteLine();
     Console.WriteLine("Newtonsoft.Json:");
     Console.WriteLine("The MIT License (MIT)\r\n\r\nCopyright (c) 2007 James Newton-King\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.");
     Console.WriteLine();
     Console.WriteLine();
     Console.WriteLine("ShellShell:");
     Console.WriteLine("The MIT License (MIT)\r\n\r\nCopyright (c) 2018 Christian Kovacs\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.");
 }
Ejemplo n.º 5
0
        private void Execute(ShellShellExecutor executor)
        {
            ApplicationSettings config = ApplicationSettings.LoadSettings();
            string key = executor.GetParameterAsString(ParameterNames.Key);

            if (config.EnvironmentVariables.ContainsKey(key))
            {
                Console.WriteLine($"{key} -> {config.EnvironmentVariables[key]}");
            }
            else if (config.Settings.ContainsKey(key))
            {
                Console.WriteLine($"{key} -> {config.Settings[key]}");
            }
            else
            {
                Console.WriteLine($"{key} -> Error Not Found");
            }
        }
Ejemplo n.º 6
0
        private void Execute(ShellShellExecutor executor)
        {
            ApplicationSettings config = ApplicationSettings.LoadSettings();
            var  environmentSets       = "";
            bool debug       = executor.GetSwitch(SwitchesNames.Debug);
            bool useSysProxy = executor.GetSwitch(SwitchesNames.UseSysProxy);

            foreach (KeyValuePair <string, string> envVar in config.EnvironmentVariables)
            {
                if (debug)
                {
                    Console.WriteLine($"set {envVar.Key}={envVar.Value}");
                }
                environmentSets += $"set {envVar.Key}={envVar.Value}&";
            }

            if (useSysProxy || (config.Settings.ContainsKey("usesystemproxy") && string.Equals(config.Settings["usesystemproxy"], "true", StringComparison.CurrentCultureIgnoreCase)))
            {
                string proxy = ProxyHelper.GetSystemProxy();
                if (!string.IsNullOrEmpty(proxy))
                {
                    environmentSets += $"set HTTP_PROXY={proxy}&";
                }

                string httpsProxy = ProxyHelper.GetSystemHttpsProxy();
                if (!string.IsNullOrEmpty(proxy))
                {
                    environmentSets += $"set HTTPS_PROXY={httpsProxy}&";
                }
            }

            var processInfo = new ProcessStartInfo
            {
                UseShellExecute = false,
                FileName        = "cmd.exe",
                Arguments       = @"/c " + environmentSets + executor.GetParameterAsString(ParameterNames.Program)
            };

            Console.WriteLine("Executing " + executor.GetParameterAsString(ParameterNames.Program));
            using (Process process = Process.Start(processInfo))
            {
                process?.WaitForExit();
            }
        }
Ejemplo n.º 7
0
        private void Execute(ShellShellExecutor executor)
        {
            ApplicationSettings config = ApplicationSettings.LoadSettings();
            string key = executor.GetParameterAsString(ParameterNames.Key);

            if (config.EnvironmentVariables.ContainsKey(key))
            {
                config.EnvironmentVariables.Remove(key);
                config.SaveSettings();
                Console.WriteLine($"Setting {key} removed!");
            }
            else if (config.Settings.ContainsKey(key))
            {
                config.Settings.Remove(key);
                config.SaveSettings();
                Console.WriteLine($"Setting {key} removed!");
            }
            else
            {
                Console.WriteLine($"Setting {key} was not set!");
            }
        }
Ejemplo n.º 8
0
 private void Execute(ShellShellExecutor executor)
 {
     Console.WriteLine("Version 1.0");
     Console.WriteLine("Maintainer: Christian Kovacs");
     Console.WriteLine("GitHub: https://github.com/Pagat-Ultimo/Groxy");
 }