File: TagidxOptions.h

package info (click to toggle)
tagcoll 1.6.3-2
  • links: PTS
  • area: main
  • in suites: etch
  • size: 2,500 kB
  • ctags: 2,062
  • sloc: cpp: 10,930; sh: 8,892; makefile: 201; lex: 54; yacc: 27
file content (185 lines) | stat: -rw-r--r-- 4,536 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#ifndef TAGIDX_OPTIONS_H
#define TAGIDX_OPTIONS_H

/*
 * Commandline parser for tagcoll
 *
 * Copyright (C) 2003,2004,2005,2006  Enrico Zini
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include <tagcoll/Commandline.h>

namespace Tagcoll {
namespace commandline {

struct TagidxOptions : public MainParser<CommandParser>
{
	struct HelpGroup : public OptionGroup
	{
		BoolOption* help;
		BoolOption* version;

		HelpGroup()
		{
			add(help = new BoolOption("help", 'h', "help"));
			add(version = new BoolOption("version", 'V', "version"));
			help->shortNames.push_back('?');
			help->description = "print an help message and exit";
			version->description = "print the program version and exit";
			description = "Help options";
		}
		~HelpGroup()
		{
			delete help;
		}
	} helpGroup;

	struct IndexGroup : public OptionGroup
	{
		ExistingFileOption* index;

		IndexGroup()
		{
			add(index		= new ExistingFileOption("index", 'I', "index"));
			index->usage = "<dir>";
			index->description = "directory where the index files are stored";

			description = "Options used to identify the index";
		}
		~IndexGroup()
		{
			delete index;
		}
	} indexGroup;

	struct OutputGroup : public OptionGroup
	{
		BoolOption* group;
		BoolOption* quiet;
		
		OutputGroup()
		{
			add(group		= new BoolOption("group", 'g', "group"));
			add(quiet		= new BoolOption("quiet", 'q', "quiet"));
			group->description = "group items with the same tagset in the output collection";
			group->longNames.push_back("group-items");
			quiet->description = "produce no output";
			description = "Options controlling transformations of output data";
		}
		~OutputGroup()
		{
			delete group;
			delete quiet;
		}
	} outputGroup;

	struct Generic : public OptionParser
	{
		Generic(TagidxOptions* cp) : OptionParser("")
		{
			add(&cp->helpGroup);
		}
	} generic;
	struct Help : public OptionParser
	{
		Help(TagidxOptions* cp) : OptionParser("help")
		{
			usage = "[command]";
			description = "print help informations";
		}
	} help;
	struct Create : public OptionParser
	{
		Create(TagidxOptions* cp) : OptionParser("create")
		{
			usage = "[files...]";
			description = "create the index from a tagged collection";
			add(&cp->indexGroup);
			add(&cp->helpGroup);
		}
	} create;
	struct Remove : public OptionParser
	{
		Remove(TagidxOptions* cp) : OptionParser("remove")
		{
			usage = "";
			description = "deletes the disk index";
			add(&cp->indexGroup);
			add(&cp->helpGroup);
		}
	} remove;
	struct AddPatch : public OptionParser
	{
		BoolOption* force;

		AddPatch(TagidxOptions* cp) : OptionParser("addpatch")
		{
			add(force = new BoolOption("force", 'f', "force"));
			force->description = "force overwrite";

			usage = "[files...]";
			description = "installs the given files as patches to the collection";
			add(&cp->indexGroup);
			add(&cp->helpGroup);
		}
	} addpatch;
	struct Compact : public OptionParser
	{
		Compact(TagidxOptions* cp) : OptionParser("compact")
		{
			usage = "";
			description = "merge the patches into the index (can cause "
						  "race conditions if invoked concurrently with other "
						  "tagidx accessing the same index)";
			add(&cp->indexGroup);
			add(&cp->helpGroup);
		}
	} compact;
	struct Cat : public OptionParser
	{
		Cat(TagidxOptions* cp) : OptionParser("cat")
		{
			usage = "";
			description = "output the collection";
			add(&cp->indexGroup);
			add(&cp->outputGroup);
			add(&cp->helpGroup);
		}
	} cat;

	TagidxOptions() : MainParser<CommandParser>("tagidx"),
		generic(this),
		help(this), create(this), remove(this), addpatch(this), compact(this), cat(this)
	{
		add(generic);
		add(help);
		add(create);
		add(remove);
		add(addpatch);
		add(compact);
		add(cat);

		usage = "<command> [options and arguments]";
		description = "Access an indexed tagged collection";
	}
};

}
}

// vim:set ts=4 sw=4:
#endif