Skip to content

Commit

Permalink
Merge pull request #46 from oblivioncth/dev
Browse files Browse the repository at this point in the history
Merge to master for v0.9.3
  • Loading branch information
oblivioncth authored Feb 13, 2023
2 parents 6287996 + f03c063 commit 5a3d1af
Show file tree
Hide file tree
Showing 36 changed files with 666 additions and 464 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.21.1)
# Project
# NOTE: DON'T USE TRAILING ZEROS IN VERSIONS
project(CLIFp
VERSION 0.9.2.1
VERSION 0.9.3
LANGUAGES CXX
DESCRIPTION "Command-line Interface for Flashpoint"
)
Expand Down Expand Up @@ -110,14 +110,14 @@ endif()

include(OB/FetchQx)
fetch_qx(
REF "v0.4.3"
REF "ae110210c06ae23f7ffb42891d45206db7fdad54"
COMPONENTS
${QX_FETCH_COMPONENTS}
)

# Fetch libfp (build and import from source)
include(OB/Fetchlibfp)
fetch_libfp("v0.1.5")
fetch_libfp("v0.2")

# Fetch QI-QMP (build and import from source)
include(OB/FetchQI-QMP)
Expand Down
29 changes: 24 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ though this isn't required as long as quotation and space use is carefully emplo
Options:
- **-i | --id:** UUID of title to make a shortcut for
- **-t | --title:** Title to make a shortcut for
- **-T | --title-strict:** Same as **-t**, but only exact matches are considered
- **-s | --subtitle:** Name of additional-app under the title to make a shortcut for. Must be used with **-t**/**-T**
- **-S | --subtitle-strict:** Same as **-s**, but only exact matches are considered
- **-p | --path:** Path to new shortcut. Path's ending with ".lnk" (Windows) or ".desktop" (Linux) will be interpreted as a named shortcut file. Any other path will be interpreted as a directory and the title will automatically be used as the filename
- **-h | --help | -?:** Prints command specific usage information

Requires:
**-i** or **-t**
Expand All @@ -108,14 +112,13 @@ Notes:

- On Linux, when providing a full shortcut path via the **--path** switch, the filename component is re-interpreted as the shortcut's display name and the actual filename is set automatically.



For example, when specifying:

CLIFp link -p "~/Desktop/Cool Name.desktop" ...

the display name of the desktop entry will be set to "Cool Name".
- On some Linux desktop environments (i.e. GNOME) the shortcut might need to manually be set to "trusted" in order to be used and displayed correctly after it is created. This option is usually available in the file's right-click context menu.
- See the **play** command notes for information regarding the **t**/**T** and **s**/**S** switches.

--------------------------------------------------------------------------------

Expand All @@ -125,11 +128,22 @@ Options:

- **-i | --id:** UUID of title to start
- **-t | --title:** Title to start
- **-r | --random:** Select a random title from the database to start. Must be followed by a library filter: all/any, game/arcade, animation/theatre
- **-T | --title-strict:** Same as **-t**, but only exact matches are considered
- **-s | --subtitle:** Name of additional-app under the title to start. Must be used with **-t**/**-T**
- **-S | --subtitle-strict:** Same as **-s**, but only exact matches are considered
- **-r | --random:** Select a random title from the database to start. Must be followed by a library filter: all/any, game/arcade, animation/theatre
- **-h | --help | -?:** Prints command specific usage information

Requires:
**-i** or **-t** or **-r**
**-i** or **-t** or **-r**

Notes:

The **-t** and **-s** switches are case-insensitive and will match any title that contains the value provided. If more than one result is found, a dialog will be presented that allows for selected the desired title; however, there is a limit to the number of matches.

Using the **-T** and **-S** switches only consider exact matches and are performed slightly faster than their more flexible counterparts.

Tip: You can use **-s** with an empty string (i.e. `-s ""`) to see all of the additional-apps for a given title.

--------------------------------------------------------------------------------

Expand All @@ -149,8 +163,9 @@ Requires:
**run** - Start Flashpoint's webserver and then execute the provided application

Options:
- **-a | --app:** Relative (to Flashpoint Directory) path of application to launch
- **-a | --app:** Relative (to Flashpoint Directory) path of application to launch
- **-p | --param:** Command-line parameters to use when starting the application
- **-h | --help | -?:** Prints command specific usage information

Requires:
**-a**
Expand All @@ -177,6 +192,7 @@ See http://www.robvanderwoude.com/escapechars.php for more information.
Options:
- **-m | --msg:** Displays an pop-up dialog with the supplied message. Used primarily for some additional apps
- **-e | --extra:** Opens an explorer window to the specified extra. Used primarily for some additional apps
- **-h | --help | -?:** Prints command specific usage information

Requires:
**-m** or **-e**
Expand Down Expand Up @@ -231,6 +247,9 @@ Once CLIFp has finished executing an exit code is reported that indicates the "e
| 23 | QMP_COMMAND_FAIL | A command error occurred with Flashpoint's QEMU instance |
| 24 | PHP_MOUNT_FAIL | The QEMU server failed to mount a data pack |
| 25 | PACK_EXTRACT_FAIL | Data pack extraction failed |
| 26 | CANT_LISTEN_DOCKER | CLIFp could not connect to Docker to listen for the server's start signal |
| 27 | DOCKER_DIDNT_START | The docker server never started |
| 28 | TOO_MANY_RESULTS | Too many results were returned from a database query |
| 101 | RAND_FILTER_NOT_VALID | The provided string for random operation was not a valid filter |
| 102 | PARENT_INVALID | The parent ID of the target additional app is missing or invalid |
| 201 | INVALID_SHORTCUT_PARAM | The provided shortcut path is not valid or there was a permissions issue |
Expand Down
36 changes: 31 additions & 5 deletions src/command/c-link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,32 @@ ErrorCode CLink::process(const QStringList& commandLine)
return ErrorCode::ID_NOT_VALID;
}
}
else if(mParser.isSet(CL_OPTION_TITLE))
else if(mParser.isSet(CL_OPTION_TITLE) || mParser.isSet(CL_OPTION_TITLE_STRICT))
{
if((errorStatus = mCore.getGameIDFromTitle(shortcutId, mParser.value(CL_OPTION_TITLE))))
// Check title
bool titleStrict = mParser.isSet(CL_OPTION_TITLE_STRICT);
QString title = titleStrict ? mParser.value(CL_OPTION_TITLE_STRICT) : mParser.value(CL_OPTION_TITLE);

if((errorStatus = mCore.findGameIdFromTitle(shortcutId, title, titleStrict)))
return errorStatus;

// Bail if canceled
if(shortcutId.isNull())
return ErrorCode::NO_ERR;

// Check subtitle
if(mParser.isSet(CL_OPTION_SUBTITLE) || mParser.isSet(CL_OPTION_SUBTITLE_STRICT))
{
bool subtitleStrict = mParser.isSet(CL_OPTION_SUBTITLE_STRICT);
QString subtitle = subtitleStrict ? mParser.value(CL_OPTION_SUBTITLE_STRICT) : mParser.value(CL_OPTION_SUBTITLE);

if((errorStatus = mCore.findAddAppIdFromName(shortcutId, shortcutId, subtitle, subtitleStrict)))
return errorStatus;

// Bail if canceled
if(shortcutId.isNull())
return ErrorCode::NO_ERR;
}
}
else
{
Expand All @@ -60,10 +82,12 @@ ErrorCode CLink::process(const QStringList& commandLine)
Fp::Db* database = mCore.fpInstall().database();

// Get entry info (also confirms that ID is present in database)
Fp::Db::EntryFilter entryFilter{.type = Fp::Db::EntryType::PrimaryThenAddApp, .id = shortcutId};

QSqlError sqlError;
Fp::Db::QueryBuffer entryInfo;

if((sqlError = database->queryEntryById(entryInfo, shortcutId)).isValid())
if((sqlError = database->queryEntrys(entryInfo, entryFilter)).isValid())
{
mCore.postError(NAME, Qx::GenericError(Qx::GenericError::Critical, Core::ERR_UNEXPECTED_SQL, sqlError.text()));
return ErrorCode::SQL_ERROR;
Expand All @@ -82,9 +106,11 @@ ErrorCode CLink::process(const QStringList& commandLine)
else if(entryInfo.source == Fp::Db::Table_Add_App::NAME)
{
// Get parent info
QUuid parentId = QUuid(entryInfo.result.value(Fp::Db::Table_Add_App::COL_PARENT_ID).toString());
Fp::Db::EntryFilter parentFilter{.type = Fp::Db::EntryType::Primary, .id = parentId};

Fp::Db::QueryBuffer parentInfo;
if((sqlError = database->queryEntryById(parentInfo,
QUuid(entryInfo.result.value(Fp::Db::Table_Add_App::COL_PARENT_ID).toString()))).isValid())
if((sqlError = database->queryEntrys(parentInfo, parentFilter)).isValid())
{
mCore.postError(NAME, Qx::GenericError(Qx::GenericError::Critical, Core::ERR_UNEXPECTED_SQL, sqlError.text()));
return ErrorCode::SQL_ERROR;
Expand Down
73 changes: 46 additions & 27 deletions src/command/c-link.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#ifndef CLINK_H
#define CLINK_H

// Qx Includes
#include <qx/utility/qx-macros.h>

// Project Includes
#include "command/command.h"

Expand All @@ -9,53 +12,69 @@ class CLink : public Command
//-Class Variables------------------------------------------------------------------------------------------------------
private:
// Status
static inline const QString STATUS_LINK = "Linking";
static inline const QString STATUS_LINK = QSL("Linking");

// General
static inline const QString DIAG_CAPTION = "Select a shortcut destination...";
static inline const QString DIAG_CAPTION = QSL("Select a shortcut destination...");

// Error Messages - Prep
static inline const QString ERR_NO_TITLE = "The title to link was not specified.";
static inline const QString ERR_CREATE_FAILED = "Failed to create shortcut.";
static inline const QString ERR_INVALID_PATH = "The provided shortcut path is not valid or a location where you do not have permissions to create a shortcut.";
static inline const QString ERR_DIFFERENT_TITLE_SRC = "The shortcut title source was expected to be %1 but instead was %2";
static inline const QString ERR_NO_TITLE = QSL("The title to link was not specified.");
static inline const QString ERR_CREATE_FAILED = QSL("Failed to create shortcut.");
static inline const QString ERR_INVALID_PATH = QSL("The provided shortcut path is not valid or a location where you do not have permissions to create a shortcut.");
static inline const QString ERR_DIFFERENT_TITLE_SRC = QSL("The shortcut title source was expected to be %1 but instead was %2");

// Logging - Messages
static inline const QString LOG_EVENT_FILE_PATH = "Shortcut path provided is for a file";
static inline const QString LOG_EVENT_DIR_PATH = "Shortcut path provided is for a folder";
static inline const QString LOG_EVENT_NO_PATH = "No shortcut path provided, user will be prompted";
static inline const QString LOG_EVENT_SEL_PATH = "Shortcut path selected: %1";
static inline const QString LOG_EVENT_DIAG_CANCEL = "Shortcut path selection canceled.";
static inline const QString LOG_EVENT_CREATED_DIR_PATH = "Created directories for shortcut: %1";
static inline const QString LOG_EVENT_CREATED_SHORTCUT = "Created shortcut to %1 at %2";
static inline const QString LOG_EVENT_FILE_PATH = QSL("Shortcut path provided is for a file");
static inline const QString LOG_EVENT_DIR_PATH = QSL("Shortcut path provided is for a folder");
static inline const QString LOG_EVENT_NO_PATH = QSL("No shortcut path provided, user will be prompted");
static inline const QString LOG_EVENT_SEL_PATH = QSL("Shortcut path selected: %1");
static inline const QString LOG_EVENT_DIAG_CANCEL = QSL("Shortcut path selection canceled.");
static inline const QString LOG_EVENT_CREATED_DIR_PATH = QSL("Created directories for shortcut: %1");
static inline const QString LOG_EVENT_CREATED_SHORTCUT = QSL("Created shortcut to %1 at %2");

// Logging - Errors

// Command line option strings
static inline const QString CL_OPT_ID_S_NAME = "i";
static inline const QString CL_OPT_ID_L_NAME = "id";
static inline const QString CL_OPT_ID_DESC = "UUID of title to make a shortcut for";
static inline const QString CL_OPT_ID_S_NAME = QSL("i");
static inline const QString CL_OPT_ID_L_NAME = QSL("id");
static inline const QString CL_OPT_ID_DESC = QSL("UUID of title to make a shortcut for");

static inline const QString CL_OPT_TITLE_S_NAME = QSL("t");
static inline const QString CL_OPT_TITLE_L_NAME = QSL("title");
static inline const QString CL_OPT_TITLE_DESC = QSL("Title to make a shortcut for");

static inline const QString CL_OPT_TITLE_STRICT_S_NAME = QSL("T");
static inline const QString CL_OPT_TITLE_STRICT_L_NAME = QSL("title-strict");
static inline const QString CL_OPT_TITLE_STRICT_DESC = QSL("Same as -t, but exact matches only");

static inline const QString CL_OPT_SUBTITLE_S_NAME = QSL("s");
static inline const QString CL_OPT_SUBTITLE_L_NAME = QSL("subtitle");
static inline const QString CL_OPT_SUBTITLE_DESC = QSL("Name of additional-app under the title to make a shortcut for. Must be used with -t / -T");

static inline const QString CL_OPT_TITLE_S_NAME = "t";
static inline const QString CL_OPT_TITLE_L_NAME = "title";
static inline const QString CL_OPT_TITLE_DESC = "Title to make a shortcut for";
static inline const QString CL_OPT_SUBTITLE_STRICT_S_NAME = QSL("S");
static inline const QString CL_OPT_SUBTITLE_STRICT_L_NAME = QSL("subtitle-strict");
static inline const QString CL_OPT_SUBTITLE_STRICT_DESC = QSL("Same as -s, but exact matches only");

static inline const QString CL_OPT_PATH_S_NAME = "p";
static inline const QString CL_OPT_PATH_L_NAME = "path";
static inline const QString CL_OPT_PATH_DESC = "Path to new shortcut. Path's ending with "".lnk""//"".desktop"" will be interpreted as a named shortcut file. "
"Any other path will be interpreted as a directory and the title will automatically be used "
"as the filename";
static inline const QString CL_OPT_PATH_S_NAME = QSL("p");
static inline const QString CL_OPT_PATH_L_NAME = QSL("path");
static inline const QString CL_OPT_PATH_DESC = QSL("Path to new shortcut. Path's ending with "".lnk""//"".desktop"" will be interpreted as a named shortcut file. "
"Any other path will be interpreted as a directory and the title will automatically be used "
"as the filename");

// Command line options
static inline const QCommandLineOption CL_OPTION_ID{{CL_OPT_ID_S_NAME, CL_OPT_ID_L_NAME}, CL_OPT_ID_DESC, "id"}; // Takes value
static inline const QCommandLineOption CL_OPTION_TITLE{{CL_OPT_TITLE_S_NAME, CL_OPT_TITLE_L_NAME}, CL_OPT_TITLE_DESC, "title"}; // Takes value
static inline const QCommandLineOption CL_OPTION_TITLE_STRICT{{CL_OPT_TITLE_STRICT_S_NAME, CL_OPT_TITLE_STRICT_L_NAME}, CL_OPT_TITLE_STRICT_DESC, "title-strict"}; // Takes value
static inline const QCommandLineOption CL_OPTION_SUBTITLE{{CL_OPT_SUBTITLE_S_NAME, CL_OPT_SUBTITLE_L_NAME}, CL_OPT_SUBTITLE_DESC, "subtitle"}; // Takes value
static inline const QCommandLineOption CL_OPTION_SUBTITLE_STRICT{{CL_OPT_SUBTITLE_STRICT_S_NAME, CL_OPT_SUBTITLE_STRICT_L_NAME}, CL_OPT_SUBTITLE_STRICT_DESC, "subtitle-strict"}; // Takes value
static inline const QCommandLineOption CL_OPTION_PATH{{CL_OPT_PATH_S_NAME, CL_OPT_PATH_L_NAME}, CL_OPT_PATH_DESC, "path"}; // Takes value
static inline const QList<const QCommandLineOption*> CL_OPTIONS_SPECIFIC{&CL_OPTION_ID, &CL_OPTION_TITLE, &CL_OPTION_PATH};
static inline const QList<const QCommandLineOption*> CL_OPTIONS_SPECIFIC{&CL_OPTION_ID, &CL_OPTION_TITLE, &CL_OPTION_TITLE_STRICT, &CL_OPTION_SUBTITLE,
&CL_OPTION_SUBTITLE_STRICT, &CL_OPTION_PATH};

public:
// Meta
static inline const QString NAME = "link";
static inline const QString DESCRIPTION = "Creates a shortcut to a Flashpoint title.";
static inline const QString NAME = QSL("link");
static inline const QString DESCRIPTION = QSL("Creates a shortcut to a Flashpoint title.");

//-Constructor----------------------------------------------------------------------------------------------------------
public:
Expand Down
Loading

0 comments on commit 5a3d1af

Please sign in to comment.