aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThierry Crozat2018-04-22 11:17:22 +0100
committerThierry Crozat2018-04-25 19:40:20 +0100
commit5907add14821b4dc9b205157c1a90c76270d5541 (patch)
treef51844b4fcf75238c2aae131263815e5c0cf05aa
parent519e02da47ff972776350fa77ad1e6876a714106 (diff)
downloadscummvm-rg350-5907add14821b4dc9b205157c1a90c76270d5541.tar.gz
scummvm-rg350-5907add14821b4dc9b205157c1a90c76270d5541.tar.bz2
scummvm-rg350-5907add14821b4dc9b205157c1a90c76270d5541.zip
BASE: Use --game to specify target for --list-saves command
This change brings the --list-saves command syntax in line with other commands.
-rw-r--r--README4
-rw-r--r--base/commandLine.cpp30
2 files changed, 17 insertions, 17 deletions
diff --git a/README b/README
index afb153dd53..30f2b6247e 100644
--- a/README
+++ b/README
@@ -1463,7 +1463,7 @@ arguments -- see the next section.
-h, --help Display a brief help text and exit
-z, --list-games Display list of supported games and exit
-t, --list-targets Display list of configured targets and exit
- --list-saves=TARGET Display a list of saved games for the game (TARGET) specified
+ --list-saves Display a list of saved games for the target specified with --game=TARGET
-a, --add Add all games from current or specified directory.
If --game=ID is passed only the game with id ID is
added. See also --detect.
@@ -2011,7 +2011,7 @@ Where 'xxx' is exact the saved game slot (i.e., 001) under ScummVM
This switch may be used to display a list of the current saved games
of the specified target game and their corresponding save slots.
- Usage: --list-saves=[TARGET], where [TARGET] is the target game.
+ Usage: --list-saves --game=[TARGET], where [TARGET] is the target game.
Engines which currently support --list-saves are:
diff --git a/base/commandLine.cpp b/base/commandLine.cpp
index f9090a864d..0ef8996ae8 100644
--- a/base/commandLine.cpp
+++ b/base/commandLine.cpp
@@ -68,7 +68,7 @@ static const char HELP_STRING[] =
" -h, --help Display a brief help text and exit\n"
" -z, --list-games Display list of supported games and exit\n"
" -t, --list-targets Display list of configured targets and exit\n"
- " --list-saves=TARGET Display a list of saved games for the game (TARGET) specified\n"
+ " --list-saves Display a list of saved games for the target specified with --game=TARGET\n"
" -a, --add Add all games from current or specified directory.\n"
" If --game=ID is passed only the game with id ID is added. See also --detect\n"
" Use --path=PATH to specify a directory.\n"
@@ -458,13 +458,8 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, const cha
END_COMMAND
#endif
- DO_LONG_OPTION("list-saves")
- // TODO: Make the argument optional. If no argument is given, list all saved games
- // for all configured targets.
- // TODO: Consider breaking the command line interface to pass the argument via the --game option
- ensureFirstCommand(command, "list-saves");
- command = "list-saves";
- END_OPTION
+ DO_LONG_COMMAND("list-saves")
+ END_COMMAND
DO_OPTION('c', "config")
END_OPTION
@@ -734,9 +729,14 @@ static void listTargets() {
}
/** List all saves states for the given target. */
-static Common::Error listSaves(const char *target) {
+static Common::Error listSaves(const Common::String &target) {
Common::Error result = Common::kNoError;
+ // TODO: Make the target argument optional. If no argument is given, list all saved games
+ // for all configured targets.
+ if (target.empty())
+ usage("You must specify a target using --game=TARGET when using --list-saves.");
+
// FIXME HACK
g_system->initBackend();
@@ -762,7 +762,7 @@ static Common::Error listSaves(const char *target) {
if (!plugin) {
return Common::Error(Common::kEnginePluginNotFound,
- Common::String::format("target '%s', gameid '%s", target, gameid.c_str()));
+ Common::String::format("target '%s', gameid '%s", target.c_str(), gameid.c_str()));
}
const MetaEngine &metaEngine = plugin->get<MetaEngine>();
@@ -770,14 +770,14 @@ static Common::Error listSaves(const char *target) {
if (!metaEngine.hasFeature(MetaEngine::kSupportsListSaves)) {
// TODO: Include more info about the target (desc, engine name, ...) ???
return Common::Error(Common::kEnginePluginNotSupportSaves,
- Common::String::format("target '%s', gameid '%s", target, gameid.c_str()));
+ Common::String::format("target '%s', gameid '%s", target.c_str(), gameid.c_str()));
} else {
// Query the plugin for a list of saved games
- SaveStateList saveList = metaEngine.listSaves(target);
+ SaveStateList saveList = metaEngine.listSaves(target.c_str());
if (saveList.size() > 0) {
// TODO: Include more info about the target (desc, engine name, ...) ???
- printf("Save states for target '%s' (gameid '%s'):\n", target, gameid.c_str());
+ printf("Save states for target '%s' (gameid '%s'):\n", target.c_str(), gameid.c_str());
printf(" Slot Description \n"
" ---- ------------------------------------------------------\n");
@@ -786,7 +786,7 @@ static Common::Error listSaves(const char *target) {
// TODO: Could also iterate over the full hashmap, printing all key-value pairs
}
} else {
- printf("There are no save states for target '%s' (gameid '%s'):\n", target, gameid.c_str());
+ printf("There are no save states for target '%s' (gameid '%s'):\n", target.c_str(), gameid.c_str());
}
}
@@ -1165,7 +1165,7 @@ bool processSettings(Common::String &command, Common::StringMap &settings, Commo
listGames();
return true;
} else if (command == "list-saves") {
- err = listSaves(settings["list-saves"].c_str());
+ err = listSaves(settings["game"]);
return true;
} else if (command == "list-themes") {
listThemes();