コード例 #1
0
ファイル: vxsqlpool.cs プロジェクト: apenwarr/versaplex
    public static void SetIniFile(string path)
    {
	if (path.e() || !File.Exists(path))
	    throw new Exception
	        (wv.fmt("Could not find config file '{0}'", path));
	inifile = new WvIni(path);
    }
コード例 #2
0
ファイル: wvutils.t.cs プロジェクト: apenwarr/versaplex
    [Test] [Category("ini")] public void ini_test()
    {
	WvIni ini = new WvIni("test.ini");
	WVPASSEQ(ini[""].Count, 2);
	WVPASSEQ(ini[""]["global item"], "i");
	WVPASSEQ(ini[""]["global 2"], "i2");
	WVPASSEQ(ini["subsEction"].Count, 3);
	WVPASSEQ(ini["subseCtion"]["2"], "3");
	WVPASSEQ(ini["nonexistent"].Count, 0);
    }
コード例 #3
0
ファイル: sm.cs プロジェクト: apenwarr/versaplex
    public static int _Main(string[] args)
    {
	// command line options
	VxCopyOpts opts = VxCopyOpts.Verbose;
    
	int verbose = (int)WvLog.L.Info;
	string outfile = null;
        var global_syms = new Dictionary<string,string>();
        var extra = new OptionSet()
            .Add("n|dry-run", delegate(string v) { opts |= VxCopyOpts.DryRun; } )
            .Add("f|force", delegate(string v) { opts |= VxCopyOpts.Destructive; } )
            .Add("v|verbose", delegate(string v) { verbose++; } )
            .Add("g|global-sym=", delegate(string v) 
                { 
                    var splitopts = StringSplitOptions.RemoveEmptyEntries;
                    char[] splitchars = {',', ';', ':'};
                    if (v.ne()) 
                        foreach (var sym in v.Split(splitchars, splitopts))
                            global_syms.Add(sym.ToLower(), null); 
                } )
	    .Add("o|output-file=", delegate(string v) { outfile = v; })
            .Parse(args);

	WvLog.maxlevel = (WvLog.L)verbose;
	
	if (extra.Count < 1)
	{
            ShowHelp();
            return 97;
	}
	
	string cmd = extra[0];
	if (cmd == "pascalgen")
	    return pascalgen_Main(extra, global_syms, outfile);
	
	WvIni bookmarks = new WvIni(
		    wv.PathCombine(wv.getenv("HOME"), ".wvdbi.ini"));
	
	string moniker = extra.Count > 1 
	    ? extra[1] : bookmarks.get("Defaults", "url", null);
        string dir     = extra.Count > 2 ? extra[2] : ".";
	
	if (cmd == "dfix")
        {
            VxDiskSchema disk = new VxDiskSchema(dir);
            bool consider_rules = true;
            if (consider_rules)
                return disk.FixSchemaData(disk.GetReplaceRules(),
                                          disk.GetFieldsToSkip());
            else
                return disk.FixSchemaData(null,null);
        }
	
	if (moniker.e())
	{
	    ShowHelp();
	    return 96;
	}
	
	// look up a bookmark if it exists, else use the provided name as a
	// moniker
	moniker = bookmarks.get("Bookmarks", moniker, moniker);

	// provide a default username/password if they weren't provided
	// FIXME: are there URLs that should have a blank username/password?
	WvUrl url = new WvUrl(moniker);
	if (url.user.e())
	    url.user = bookmarks.get("Defaults", "user");
	if (url.password.e())
	    url.password = bookmarks.get("Defaults", "password");
	    
	using (var backend = GetBackend(url))
	{
	    bookmarks.set("Defaults", "url", url.ToString(true));
	    bookmarks.maybeset("Defaults", "user", url.user);
	    bookmarks.maybeset("Defaults", "password", url.password);
	    
	    string p = url.path.StartsWith("/") 
		? url.path.Substring(1) : url.path;
	    bookmarks.set("Bookmarks", p, url.ToString(true));
	    
	    try {
		bookmarks.save();
	    } catch (IOException) {
		// not a big deal if we can't save our bookmarks.
	    }
	    
	    if (cmd == "remote")
		return 0; // just saved the bookmark, so we're done
	    else if (cmd == "pull")
		do_pull(backend, dir, opts);
	    else if (cmd == "push")
		do_push(backend, dir, opts);
	    else if (cmd == "dpull")
		do_dpull(backend, dir, opts);
	    else if (cmd == "dpush")
		do_dpush(backend, dir, opts);
	    else
	    {
		Console.Error.WriteLine("\nUnknown command '{0}'\n", cmd);
		ShowHelp();
	    }
	}
	
	return 0;
    }