mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
added commands for adding/removing existing libraries
This commit is contained in:
parent
1ceda5b9d7
commit
7ade7e677a
@ -56,6 +56,28 @@ void ConsoleUILibraryCreator::updateLibrary(const QString & path)
|
|||||||
eventLoop.exec();
|
eventLoop.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConsoleUILibraryCreator::addExistingLibrary(const QString & name, const QString & path)
|
||||||
|
{
|
||||||
|
//TODO add error handling
|
||||||
|
YACReaderLibraries yacreaderLibraries;
|
||||||
|
yacreaderLibraries.load();
|
||||||
|
yacreaderLibraries.addLibrary(name, path);
|
||||||
|
yacreaderLibraries.save();
|
||||||
|
|
||||||
|
std::cout << "Library added : " << name.toUtf8().constData() << " at " << path.toUtf8().constData() << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConsoleUILibraryCreator::removeLibrary(const QString & name)
|
||||||
|
{
|
||||||
|
//TODO add error handling
|
||||||
|
YACReaderLibraries yacreaderLibraries;
|
||||||
|
yacreaderLibraries.load();
|
||||||
|
yacreaderLibraries.remove(name);
|
||||||
|
yacreaderLibraries.save();
|
||||||
|
|
||||||
|
std::cout << "Library removed : " << name.toUtf8().constData() << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
void ConsoleUILibraryCreator::newComic(const QString & /*relativeComicPath*/, const QString & /*coverPath*/)
|
void ConsoleUILibraryCreator::newComic(const QString & /*relativeComicPath*/, const QString & /*coverPath*/)
|
||||||
{
|
{
|
||||||
numComicsProcessed++;
|
numComicsProcessed++;
|
||||||
|
@ -10,6 +10,8 @@ public:
|
|||||||
explicit ConsoleUILibraryCreator(QObject *parent = 0);
|
explicit ConsoleUILibraryCreator(QObject *parent = 0);
|
||||||
void createLibrary(const QString & name, const QString & path);
|
void createLibrary(const QString & name, const QString & path);
|
||||||
void updateLibrary(const QString & path);
|
void updateLibrary(const QString & path);
|
||||||
|
void addExistingLibrary(const QString & name, const QString & path);
|
||||||
|
void removeLibrary(const QString & name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint numComicsProcessed;
|
uint numComicsProcessed;
|
||||||
|
@ -119,7 +119,7 @@ int main( int argc, char ** argv )
|
|||||||
parser.setApplicationDescription(QCoreApplication::tr("\nYACReaderLibraryServer is the headless (no gui) version of YACReaderLibrary"));
|
parser.setApplicationDescription(QCoreApplication::tr("\nYACReaderLibraryServer is the headless (no gui) version of YACReaderLibrary"));
|
||||||
parser.addHelpOption();
|
parser.addHelpOption();
|
||||||
parser.addVersionOption();
|
parser.addVersionOption();
|
||||||
parser.addPositionalArgument("command", "The command to execute. [start, create-library, update-library, list-libraries]");
|
parser.addPositionalArgument("command", "The command to execute. [start, create-library, update-library, add-library, remove-library, list-libraries]");
|
||||||
|
|
||||||
parser.parse(QCoreApplication::arguments());
|
parser.parse(QCoreApplication::arguments());
|
||||||
|
|
||||||
@ -249,6 +249,61 @@ int main( int argc, char ** argv )
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
else if(command == "add-library")
|
||||||
|
{
|
||||||
|
QCommandLineParser parser;
|
||||||
|
|
||||||
|
parser.addHelpOption();
|
||||||
|
|
||||||
|
parser.parse(QCoreApplication::arguments());
|
||||||
|
|
||||||
|
parser.clearPositionalArguments();
|
||||||
|
parser.addPositionalArgument("add-library", "Adds an exiting library named \"name\" at the specified origin <path>");
|
||||||
|
parser.addPositionalArgument("name", "Library name", "\"name\"");
|
||||||
|
parser.addPositionalArgument("path", "Path to the folder where the library is", "<path>");
|
||||||
|
parser.process(*app);
|
||||||
|
|
||||||
|
const QStringList args = parser.positionalArguments();
|
||||||
|
if(args.length() != 3)
|
||||||
|
{
|
||||||
|
parser.showHelp();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QStringList addArgs = parser.positionalArguments();
|
||||||
|
|
||||||
|
ConsoleUILibraryCreator * libraryCreatorUI = new ConsoleUILibraryCreator;
|
||||||
|
libraryCreatorUI->addExistingLibrary(addArgs.at(1), addArgs.at(2));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if(command == "remove-library")
|
||||||
|
{
|
||||||
|
QCommandLineParser parser;
|
||||||
|
|
||||||
|
parser.addHelpOption();
|
||||||
|
|
||||||
|
parser.parse(QCoreApplication::arguments());
|
||||||
|
|
||||||
|
parser.clearPositionalArguments();
|
||||||
|
parser.addPositionalArgument("remove-library", "Removes a library named \"name\" from the list of libraries");
|
||||||
|
parser.addPositionalArgument("name", "Library name", "\"name\"");
|
||||||
|
parser.process(*app);
|
||||||
|
|
||||||
|
const QStringList args = parser.positionalArguments();
|
||||||
|
if(args.length() != 2)
|
||||||
|
{
|
||||||
|
parser.showHelp();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QStringList removeArgs = parser.positionalArguments();
|
||||||
|
|
||||||
|
ConsoleUILibraryCreator * libraryCreatorUI = new ConsoleUILibraryCreator;
|
||||||
|
libraryCreatorUI->removeLibrary(removeArgs.at(1));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
else if(command == "list-libraries")
|
else if(command == "list-libraries")
|
||||||
{
|
{
|
||||||
YACReaderLibraries libraries = DBHelper::getLibraries();
|
YACReaderLibraries libraries = DBHelper::getLibraries();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user