~ubuntu-branches/ubuntu/vivid/debtags/vivid-proposed

« back to all changes in this revision

Viewing changes to tools/DebtagsOptions.h

  • Committer: Bazaar Package Importer
  • Author(s): Enrico Zini
  • Date: 2006-03-18 20:31:47 UTC
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20060318203147-d9uzdeong5f5nk14
Tags: 1.5.5
* Added dumpavail command.
* Don't rebuild the database on install: apt-index-watcher does it instead.
  Closes: #357103.
* Compiles with g++ 4.1.  Closes: #357360.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef DEBTAGS_OPTIONS_H
 
2
#define DEBTAGS_OPTIONS_H
 
3
 
 
4
/*
 
5
 * Commandline parser for tagcoll
 
6
 *
 
7
 * Copyright (C) 2003,2004,2005,2006  Enrico Zini
 
8
 * 
 
9
 * This program is free software; you can redistribute it and/or modify
 
10
 * it under the terms of the GNU General Public License as published by
 
11
 * the Free Software Foundation; either version 2 of the License, or
 
12
 * (at your option) any later version.
 
13
 * 
 
14
 * This program is distributed in the hope that it will be useful,
 
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
 * GNU General Public License for more details.
 
18
 * 
 
19
 * You should have received a copy of the GNU General Public License
 
20
 * along with this program; if not, write to the Free Software
 
21
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
22
 */
 
23
 
 
24
#include <tagcoll/Commandline.h>
 
25
 
 
26
namespace Tagcoll {
 
27
namespace commandline {
 
28
 
 
29
struct DebtagsOptions : public MainParser<CommandParser>
 
30
{
 
31
        struct HelpGroup : public OptionGroup
 
32
        {
 
33
                BoolOption* help;
 
34
                BoolOption* version;
 
35
 
 
36
                HelpGroup()
 
37
                {
 
38
                        add(help = new BoolOption("help", 'h', "help"));
 
39
                        add(version = new BoolOption("version", 'V', "version"));
 
40
                        help->shortNames.push_back('?');
 
41
                        help->description = "print an help message and exit";
 
42
                        version->description = "print the program version and exit";
 
43
                        description = "Help options";
 
44
                }
 
45
                ~HelpGroup()
 
46
                {
 
47
                        delete help; delete version;
 
48
                }
 
49
        } helpGroup;
 
50
 
 
51
        struct OutputGroup : public OptionGroup
 
52
        {
 
53
                BoolOption* group;
 
54
                BoolOption* quiet;
 
55
                BoolOption* names;
 
56
                BoolOption* verbose;
 
57
                BoolOption* debug;
 
58
                
 
59
                OutputGroup()
 
60
                {
 
61
                        add(group               = new BoolOption("group", 0, "group"));
 
62
                        add(quiet               = new BoolOption("quiet", 'q', "quiet"));
 
63
                        add(names               = new BoolOption("names", 0, "names"));
 
64
                        add(verbose             = new BoolOption("verbose", 'v', "verbose"));
 
65
                        add(debug               = new BoolOption("debug", 0, "debug"));
 
66
                        group->description = "group items with the same tagset in the output collection";
 
67
                        group->longNames.push_back("group-items");
 
68
                        quiet->description = "do not write anything to standard output";
 
69
                        names->description = "output only the names of the packages";
 
70
                        verbose->description = "enable verbose output";
 
71
                        debug->description = "enable debugging output (including verbose output)";
 
72
                        description = "Options controlling transformations of output data";
 
73
                }
 
74
                ~OutputGroup()
 
75
                {
 
76
                        delete group;
 
77
                        delete quiet;
 
78
                        delete names;
 
79
                        delete verbose;
 
80
                        delete debug;
 
81
                }
 
82
        } outputGroup;
 
83
 
 
84
        struct MatchGroup : public OptionGroup
 
85
        {
 
86
                BoolOption* invert;
 
87
 
 
88
                MatchGroup()
 
89
                {
 
90
                        add(invert = new BoolOption("invert", 'i', "invert"));
 
91
                        invert->description = "invert the match, selecting non-matching items";
 
92
                        description = "Options controlling matching of packages";
 
93
                }
 
94
                ~MatchGroup()
 
95
                {
 
96
                        delete invert;
 
97
                }
 
98
        } matchGroup;
 
99
 
 
100
 
 
101
        struct Generic : public OptionParser
 
102
        {
 
103
                Generic(DebtagsOptions* cp) : OptionParser("")
 
104
                {
 
105
                        add(&cp->helpGroup);
 
106
                }
 
107
        } generic;
 
108
        struct Help : public OptionParser
 
109
        {
 
110
                Help(DebtagsOptions* cp) : OptionParser("help")
 
111
                {
 
112
                        usage = "[command]";
 
113
                        description = "print help informations";
 
114
                }
 
115
        } help;
 
116
        struct Update : public OptionParser
 
117
        {
 
118
                BoolOption* local;
 
119
 
 
120
                Update(DebtagsOptions* cp) : OptionParser("update")
 
121
                {
 
122
                        add(local = new BoolOption("local", 0, "local"));
 
123
                        local->usage = "";
 
124
                        local->description = "do not download files when performing an update";
 
125
                        usage = "";
 
126
                        description = "updates the package tag database (requires root)";
 
127
                        longDescription =
 
128
                                "Collect package tag data from the sources listed in "
 
129
                                "/etc/debtags/sources.list, then regenerate the debtags "
 
130
                                "tag database and main index.\n"
 
131
                                "It needs to be run as root";
 
132
                        add(&cp->helpGroup);
 
133
                }
 
134
        } update;
 
135
        struct Selfcheck : public OptionParser
 
136
        {
 
137
                Selfcheck(DebtagsOptions* cp) : OptionParser("selfcheck")
 
138
                {
 
139
                        usage = "";
 
140
                        description = "perform a series of internal self checks using the current tag data";
 
141
                        add(&cp->helpGroup);
 
142
                }
 
143
        } selfcheck;
 
144
        struct Check : public OptionParser
 
145
        {
 
146
                Check(DebtagsOptions* cp) : OptionParser("check")
 
147
                {
 
148
                        usage = "<file>";
 
149
                        description =
 
150
                                "check that all the tags in the given tagged collection are present "
 
151
                                "in the tag vocabulary.  Checks the main database if no file is "
 
152
                                "specified";
 
153
                        add(&cp->helpGroup);
 
154
                }
 
155
        } check;
 
156
        struct Tagcat : public OptionParser
 
157
        {
 
158
                Tagcat(DebtagsOptions* cp) : OptionParser("tagcat")
 
159
                {
 
160
                        usage = "";
 
161
                        description = "output the tag vocabulary";
 
162
                        add(&cp->helpGroup);
 
163
                }
 
164
        } tagcat;
 
165
        struct Tagshow : public OptionParser
 
166
        {
 
167
                Tagshow(DebtagsOptions* cp) : OptionParser("tagshow")
 
168
                {
 
169
                        usage = "<tag>";
 
170
                        description = "show the vocabulary informations about a tag";
 
171
                        add(&cp->helpGroup);
 
172
                }
 
173
        } tagshow;
 
174
        struct Tagsearch : public OptionParser
 
175
        {
 
176
                Tagsearch(DebtagsOptions* cp) : OptionParser("tagsearch")
 
177
                {
 
178
                        usage = "<string [string [string ...]]>";
 
179
                        description = "show a summary of all tags whose data contains the given strings";
 
180
                        add(&cp->helpGroup);
 
181
                }
 
182
        } tagsearch;
 
183
        struct Show : public OptionParser
 
184
        {
 
185
                Show(DebtagsOptions* cp) : OptionParser("show")
 
186
                {
 
187
                        usage = "<pkg>";
 
188
                        description = "show informations about a package, like apt-cache show does, but "
 
189
                                                  "adding the tag informations from the debtags index";
 
190
                        add(&cp->helpGroup);
 
191
                }
 
192
        } show;
 
193
        struct Related : public OptionParser
 
194
        {
 
195
                IntOption* distance;
 
196
                
 
197
                Related(DebtagsOptions* cp) : OptionParser("related")
 
198
                {
 
199
                        add(distance = new IntOption("distance", 'd', "distance"));
 
200
                        distance->description = "set the maximum distance to use for the \"related\" command (defaults to 0)";
 
201
                        
 
202
                        usage = "<pkg1[,pkg2[,pkg3...]]>";
 
203
                        description = "show packages related to the given one(s)";
 
204
                        longDescription =
 
205
                                "Output a list of the packages that are related to the given package or list of packages.  "
 
206
                                "If more than one package are to be specified, separate them with commas.\n"
 
207
                                "The --distance option can be used to control how closely related the output "
 
208
                                "packages should be from the package(s) specified.";
 
209
                        examples = "debtags related mutt,mozilla-browser";
 
210
 
 
211
                        add(&cp->helpGroup);
 
212
                }
 
213
                ~Related()
 
214
                {
 
215
                        delete distance;
 
216
                }
 
217
        } related;
 
218
        struct Cat : public OptionParser
 
219
        {
 
220
                Cat(DebtagsOptions* cp) : OptionParser("cat")
 
221
                {
 
222
                        usage = "";
 
223
                        description = "output the full package tag database";
 
224
                        add(&cp->outputGroup);
 
225
                        add(&cp->helpGroup);
 
226
                }
 
227
        } cat;
 
228
        struct Dumpavail : public OptionParser
 
229
        {
 
230
                Dumpavail(DebtagsOptions* cp) : OptionParser("dumpavail")
 
231
                {
 
232
                        usage = "[tag expression]";
 
233
                        description = "output the full package database";
 
234
                        add(&cp->matchGroup);
 
235
                        add(&cp->helpGroup);
 
236
                }
 
237
        } dumpavail;
 
238
        struct Search : public OptionParser
 
239
        {
 
240
                Search(DebtagsOptions* cp) : OptionParser("search")
 
241
                {
 
242
                        usage = "<tag expression>";
 
243
                        description =
 
244
                                "output the names and descriptions of the packages that match"
 
245
                                "the given tag expression";
 
246
                        add(&cp->matchGroup);
 
247
                        add(&cp->helpGroup);
 
248
                }
 
249
        } search;
 
250
        struct Grep : public OptionParser
 
251
        {
 
252
                Grep(DebtagsOptions* cp) : OptionParser("grep")
 
253
                {
 
254
                        usage = "<tag expression>";
 
255
                        description =
 
256
                                "output the lines of the full package tag database that match"
 
257
                                "the given tag expression";
 
258
                        add(&cp->matchGroup);
 
259
                        add(&cp->outputGroup);
 
260
                        add(&cp->helpGroup);
 
261
                }
 
262
        } grep;
 
263
        struct Install : public OptionParser
 
264
        {
 
265
                Install(DebtagsOptions* cp) : OptionParser("install")
 
266
                {
 
267
                        usage = "<tag expression>";
 
268
                        description =
 
269
                                "apt-get install the packages that match the given tag expression";
 
270
                        longDescription =
 
271
                                "Invokes apt-get install with the names of the packages matched "
 
272
                                "by the given tag expression.  If you want to see what packages "
 
273
                                "would be installed you can use debtags search, as "
 
274
                                "debtags install just calls apt-get install on all "
 
275
                                "the results of an equivalent debtags search.  Please note "
 
276
                                "that debtags install is just a prototype feature useful "
 
277
                                "for experimenting in some environments like Custom Debian "
 
278
                                "Distributions.  For this reason it is suggested that you "
 
279
                                "use debtags just as a way to find packages, and "
 
280
                                "proper package managers as the way to install them";
 
281
                        add(&cp->matchGroup);
 
282
                        add(&cp->helpGroup);
 
283
                }
 
284
        } install;
 
285
        struct Diff : public OptionParser
 
286
        {
 
287
                Diff(DebtagsOptions* cp) : OptionParser("diff")
 
288
                {
 
289
                        usage = "[filename]";
 
290
                        description =
 
291
                                "create a tag patch between the current tag database and the tag"
 
292
                                "collection [filename].  Standard input is used if filename is not specified";
 
293
                        add(&cp->helpGroup);
 
294
 
 
295
                        aliases.push_back("mkpatch");
 
296
                }
 
297
        } diff;
 
298
        struct Maintainers : public OptionParser
 
299
        {
 
300
                Maintainers(DebtagsOptions* cp) : OptionParser("maintainers")
 
301
                {
 
302
                        usage = "";
 
303
                        description =
 
304
                                "create a tagged collection of maintainers and the tags of the"
 
305
                                "packages they maintain";
 
306
                        add(&cp->outputGroup);
 
307
                        add(&cp->helpGroup);
 
308
                }
 
309
        } maintainers;
 
310
        struct Tag : public OptionParser
 
311
        {
 
312
                Tag(DebtagsOptions* cp) : OptionParser("tag")
 
313
                {
 
314
                        usage = "{add|rm|ls} <package> [tags...]";
 
315
                        description = "view and edit the tags for a package";
 
316
                        longDescription =
 
317
                                "General manipulation of tags, useful for automation in scripts.\n"
 
318
                                "It can be used in three ways:\n"
 
319
                                "tag add <package> <tags...> will add the tags to the given package\n"
 
320
                            "tag rm <package> <tags...> will remove the tags from the given package\n"
 
321
                                "tag ls <package> will output the names of the tags of the given package";
 
322
                        add(&cp->helpGroup);
 
323
                }
 
324
        } tag;
 
325
        struct Submit : public OptionParser
 
326
        {
 
327
                Submit(DebtagsOptions* cp) : OptionParser("submit")
 
328
                {
 
329
                        usage = "[patch]";
 
330
                        description =
 
331
                                "mail the given patch file to the central tag repository."
 
332
                                "If [patch] is omitted, mail the local tag modifications.";
 
333
                        add(&cp->helpGroup);
 
334
                }
 
335
        } submit;
 
336
        struct Todo : public OptionParser
 
337
        {
 
338
                Todo(DebtagsOptions* cp) : OptionParser("todo")
 
339
                {
 
340
                        usage = "";
 
341
                        description = "print a list of the installed packages that are not yet tagged";
 
342
                        add(&cp->helpGroup);
 
343
                }
 
344
        } todo;
 
345
        struct Score : public OptionParser
 
346
        {
 
347
                Score(DebtagsOptions* cp) : OptionParser("score")
 
348
                {
 
349
                        usage = "";
 
350
                        description =
 
351
                                "score uninstalled packages according to how often their tags "
 
352
                                "appear in the packages that are installed already";
 
353
                        add(&cp->helpGroup);
 
354
                }
 
355
        } score;
 
356
        struct Facetcoll : public OptionParser
 
357
        {
 
358
                Facetcoll(DebtagsOptions* cp) : OptionParser("facetcoll")
 
359
                {
 
360
                        usage = "";
 
361
                        description =
 
362
                                "print the tagged collection where each package is tagged with"
 
363
                                "its facets only.  Useful for further processing via tagcoll";
 
364
                        add(&cp->outputGroup);
 
365
                        add(&cp->helpGroup);
 
366
                }
 
367
        } facetcoll;
 
368
        struct Stats : public OptionParser
 
369
        {
 
370
                Stats(DebtagsOptions* cp) : OptionParser("stats")
 
371
                {
 
372
                        usage = "";
 
373
                        description = "print statistics about Debtags";
 
374
                        add(&cp->helpGroup);
 
375
                }
 
376
        } stats;
 
377
        struct Todoreport : public OptionParser
 
378
        {
 
379
                Todoreport(DebtagsOptions* cp) : OptionParser("todoreport")
 
380
                {
 
381
                        usage = "";
 
382
                        description = "print a report of packages needing work";
 
383
                        add(&cp->helpGroup);
 
384
                }
 
385
        } todoreport;
 
386
        struct SmartSearch : public OptionParser
 
387
        {
 
388
                SmartSearch(DebtagsOptions* cp) : OptionParser("smartsearch")
 
389
                {
 
390
                        usage = "<word [word1 [+tag [-tag1 ...]]]>";
 
391
                        description =
 
392
                                "Perform a keyword search integrated with related packages.\n"
 
393
                                "A + prefix indicates a wanted tag.  A - prefix indicates "
 
394
                                "an unwanted tag.  Other words indicate keywords to search.\n"
 
395
                                "Remember to use '--' before unwanted tags to avoid to have "
 
396
                                "them interpreted as commandline switches.\n";
 
397
                        add(&cp->helpGroup);
 
398
                }
 
399
        } smartsearch;
 
400
 
 
401
        DebtagsOptions() : MainParser<CommandParser>("debtags"),
 
402
                generic(this), help(this), update(this), selfcheck(this), check(this),
 
403
                tagcat(this), tagshow(this), tagsearch(this), show(this),
 
404
                related(this), cat(this), dumpavail(this), search(this), grep(this), install(this),
 
405
                diff(this), maintainers(this), tag(this), submit(this), todo(this),
 
406
                score(this), facetcoll(this), stats(this), todoreport(this),
 
407
                smartsearch(this)
 
408
        {
 
409
                add(generic);
 
410
                add(help);
 
411
                add(update);
 
412
                add(selfcheck);
 
413
                add(check);
 
414
                add(tagcat);
 
415
                add(tagshow);
 
416
                add(tagsearch);
 
417
                add(show);
 
418
                add(related);
 
419
                add(cat);
 
420
                add(dumpavail);
 
421
                add(search);
 
422
                add(grep);
 
423
                add(install);
 
424
                add(diff);
 
425
                add(maintainers);
 
426
                add(tag);
 
427
                add(submit);
 
428
                add(todo);
 
429
                add(score);
 
430
                add(facetcoll);
 
431
                add(stats);
 
432
                add(todoreport);
 
433
                add(smartsearch);
 
434
 
 
435
                usage = "<command> [options and arguments]";
 
436
                description = "Commandline interface to access and manipulate Debian Package Tags";
 
437
        }
 
438
};
 
439
 
 
440
}
 
441
}
 
442
 
 
443
// vim:set ts=4 sw=4:
 
444
#endif