Esempio n. 1
0
        public void RemoteHostParser1()
        {
            RemoteHost remote1 = RemoteHost.Parse("[email protected]");

            Assert.AreEqual("user", remote1.Username);
            Assert.AreEqual("", remote1.Password);
            Assert.AreEqual("192.168.0.1", remote1.Host);
            Assert.AreEqual(22, remote1.Port);

            RemoteHost remote2 = RemoteHost.Parse("user:p@[email protected]:2244");

            Assert.AreEqual("user", remote2.Username);
            Assert.AreEqual("p@sSw0rD", remote2.Password);
            Assert.AreEqual("ec2-eu-central-1.amazon.aws.com", remote2.Host);
            Assert.AreEqual(2244, remote2.Port);

            RemoteHost remote3 = RemoteHost.Parse(@"mother_fuck-3r:v3ry_str0ng-#\@255.255.255.255:65535");

            Assert.AreEqual(@"mother_fuck-3r", remote3.Username);
            Assert.AreEqual(@"v3ry_str0ng-#\", remote3.Password);
            Assert.AreEqual("255.255.255.255", remote3.Host);
            Assert.AreEqual(65535, remote3.Port);
        }
Esempio n. 2
0
        private static void ProcessArgs(String[] args)
        {
            for (int idx = 0; idx < args.Length; idx++)
            {
                switch (args[idx])
                {
                case "-s":
                case "--substitute-path":
                    String[] subst = TakeArg(args, ref idx).Split(new[] { '=' }, 2);
                    if (subst.Length != 2)
                    {
                        throw new ApplicationException("--substitute-path requires next arg to be like '/path/before=/path/after'");
                    }
                    AbsoluteCrosspath[] pair = new AbsoluteCrosspath[2];
                    for (int i = 0; i < 2; ++i)
                    {
                        try {
                            pair[i] = Crosspath.FromString(subst[i]) as AbsoluteCrosspath;
                        }
                        catch (Exception e) {
                            throw new PolymorphismException($"{e.GetType()}: '{subst[i]}' is not a valid absolute path");
                        }
                    }
                    config.Substitutions.Add(new Tuple <AbsoluteCrosspath, AbsoluteCrosspath>(pair[0], pair[1]));
                    break;

                case "-b":
                case "--base-dir":
                    config.BaseDir = AbsoluteCrosspath.FromString(TakeArg(args, ref idx));
                    break;

#if PATH_BASED_FILTERING
                case "--include":
                    config.IncludeFilesFrom.Add(Crosspath.FromString(TakeArg(args, ref idx)));
                    break;

                case "--exclude":
                    config.ExcludeFilesFrom.Add(Crosspath.FromString(TakeArg(args, ref idx)));
                    break;
#endif

                case "-o":
                case "--output-dir":
                    config.Outdir = TakeArg(args, ref idx);
                    break;

                case "-f":
                case "--file":
                    config.InputFile = TakeArg(args, ref idx);
                    break;

                case "-r":
                case "--remote":
                    RemoteHost remote = RemoteHost.Parse(TakeArg(args, ref idx));
                    config.AssignRemote(remote);
                    break;

                case "-D":
                case "--define":
                    config.OverrideDefines.Add(new Define(TakeArg(args, ref idx)));
                    break;

                case "--exclude-compiler":
                    config.ExcludeCompilers.Add(Crosspath.FromString(TakeArg(args, ref idx)));
                    break;

                case "--relax-include-dirs-order":
                    config.RelaxIncludeDirsOrder = true;
                    break;

                case "--randomize-outdir":
                    config.Outdir = Path.Combine(config.Outdir, new Random().Next().ToString("x8"));
                    break;

                case "--open-now":
                    config.OpenSolution = true;
                    break;

                case "--debug":
                    Logger.Level = LogLevel.Debug;
                    break;

                case "--help":
                    ShowHelp();
                    return;

                default:
                    throw new Exception($"Unknown command line parameter '{args[idx]}");
                }
            }
        }
Esempio n. 3
0
 private RemoteHost InitRemoteHost()
 {
     return(RemoteHost.Parse(File.ReadAllText(@"C:\VCXProjWriterRemote.txt")));
 }