Add a 'diff' command that basically does the same as WhatsNew -u
[vng.git] / src / commands / Diff.cpp
blobcd43c59c575fec13aebd3fd0b52b0bd85f29d74a
1 /*
2 * This file is part of the vng project
3 * Copyright (C) 2009 Thomas Zander <tzander@trolltech.com>
4 * Copyright (C) 2002-2004 David Roundy
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "Diff.h"
21 #include "../CommandLineParser.h"
22 // #include "../Logger.h"
23 // #include "../GitRunner.h"
24 // #include "../hunks/ChangeSet.h"
25 #include "WhatsNew.h"
27 // #include <QFile>
28 // #include <QDir>
29 #include <QDebug>
31 static const CommandLineOption options[] = {
32 {"--to-match PATTERN", "select changes up to a patch matching PATTERN"},
33 {"--to-patch REGEXP", "select changes up to a patch matching REGEXP"},
34 // {"--to-tag REGEXP", "select changes up to a tag matching REGEXP"},
35 {"--from-match PATTERN", "select changes starting with a patch matching PATTERN"},
36 {"--from-patch REGEXP", "select changes starting with a patch matching REGEXP"},
37 // {"--from-tag REGEXP", "select changes starting with a tag matching REGEXP"},
38 {"-n, --last NUMBER", "select the last NUMBER patches"},
39 {"--match PATTERN", "select patches matching PATTERN"},
40 {"-p, --patches REGEXP", "select patches matching REGEXP"},
41 // {"-t, --tags=REGEXP", "select tags matching REGEXP"},
42 // {"--reverse", "show changes in reverse order"},
43 CommandLineLastOption
46 Diff::Diff()
47 : AbstractCommand("diff")
49 CommandLineParser::addOptionDefinitions(options);
50 CommandLineParser::setArgumentDefinition("diff [FILE or DIRECTORY]" );
53 AbstractCommand::ReturnCodes Diff::run()
55 if (! checkInRepository())
56 return NotInRepo;
58 if (CommandLineParser::instance()->options().isEmpty()) {
59 WhatsNew wn;
60 return wn.printWhatsNew(true, false);
63 moveToRoot();
64 qDebug() << "not implemented yet...";
66 return Ok;
69 QString Diff::argumentDescription() const
71 return "[FILE or DIRECTORY]";
74 QString Diff::commandDescription() const
76 return "Diff can be used to create a diff between two versions which are in your\n"
77 "repository. Specifying just --from-patch will get you a diff against\n"
78 "your working copy. If you give diff no version arguments, it gives\n"
79 "you the same information as whatsnew except that the patch is\n"
80 "formatted as the output of a diff command\n";