fix sync add command, help text for other cmds (#82)

Problem was that the way the add sync folder command was handling local and remote path was based on the previous CLI processor, i.e., one string for all args. This patch updates it for CLI11.hpp
This commit is contained in:
Levi Neely 2024-12-14 11:56:30 +01:00 committed by GitHub
parent bc1bba6ec7
commit 8d4baaa1b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 16 deletions

View File

@ -332,10 +332,10 @@ void process_commands() {
// crypto subcommands // crypto subcommands
auto start_crypto_cmd = crypto_cmd->add_subcommand("start", "Start crypto"); auto start_crypto_cmd = crypto_cmd->add_subcommand("start", "Start crypto");
std::string crypto_arg; std::string start_crypto_pwd;
start_crypto_cmd->add_option("arg", crypto_arg, "Crypto argument") start_crypto_cmd->add_option("password", start_crypto_pwd, "Crypto password")
->required(); ->required();
start_crypto_cmd->callback([&] { start_crypto(crypto_arg.c_str()); }); start_crypto_cmd->callback([&] { start_crypto(start_crypto_pwd.c_str()); });
crypto_cmd->add_subcommand("stop", "Stop crypto")->callback(stop_crypto); crypto_cmd->add_subcommand("stop", "Stop crypto")->callback(stop_crypto);
@ -345,22 +345,22 @@ void process_commands() {
->callback(list_sync_folders); ->callback(list_sync_folders);
auto sync_add_cmd = sync_cmd->add_subcommand("add", "Add sync folder"); auto sync_add_cmd = sync_cmd->add_subcommand("add", "Add sync folder");
std::string syncadd_arg; std::string syncadd_lpath, syncadd_rpath;
sync_add_cmd->add_option("arg", syncadd_arg, "Paths")->required(); sync_add_cmd->add_option("localpath", syncadd_lpath, "Local Path")->required();
sync_add_cmd->add_option("remotepath", syncadd_rpath, "Remote Path")->required();
sync_add_cmd->callback([&] { sync_add_cmd->callback([&] {
auto [lpath, rpath] = split_paths(syncadd_arg.c_str()); add_sync_folder(syncadd_lpath, syncadd_rpath);
add_sync_folder(lpath, rpath);
}); });
auto sync_remove_cmd = auto sync_remove_cmd =
sync_cmd->add_subcommand("remove", "Remove sync folder")->alias("rm"); sync_cmd->add_subcommand("remove", "Remove sync folder (use ls to get folder ID)")->alias("rm");
std::string syncrm_arg; std::string syncrm_fid;
sync_remove_cmd->add_option("arg", syncrm_arg, "Path")->required(); sync_remove_cmd->add_option("folderid", syncrm_fid, "Folder ID")->required();
sync_remove_cmd->callback([&] { remove_sync_folder(syncrm_arg.c_str()); }); sync_remove_cmd->callback([&] { remove_sync_folder(syncrm_fid.c_str()); });
// command loop // command loop
while (true) { while (true) {
std::cout << "> "; std::cout << "pcloud> ";
std::string line; std::string line;
if (!std::getline(std::cin, line)) if (!std::getline(std::cin, line))
break; break;

View File

@ -42,15 +42,14 @@
#include "pcache.h" #include "pcache.h"
#include "pcloudcrypto.h" #include "pcloudcrypto.h"
#include "pcrypto.h" #include "pcrypto.h"
#include "pdiff.h"
#include "pfileops.h" #include "pfileops.h"
#include "pfolder.h" #include "pfolder.h"
#include "pfs.h"
#include "plibs.h" #include "plibs.h"
#include "pmemlock.h" #include "pmemlock.h"
#include "pnetlibs.h" #include "pnetlibs.h"
#include "psettings.h" #include "psettings.h"
#include "pssl.h" #include "pssl.h"
#include "pstatus.h"
#include <string.h> #include <string.h>
#define PSYNC_CRYPTO_API_ERR_INTERNAL -511 #define PSYNC_CRYPTO_API_ERR_INTERNAL -511

View File

@ -33,9 +33,9 @@
#define _PCLOUD_CRYPTO_H #define _PCLOUD_CRYPTO_H
#include "papi.h" #include "papi.h"
#include "pcompiler.h"
#include "pcrypto.h" #include "pcrypto.h"
#include "pfs.h" #include "pfsfolder.h"
#include "psynclib.h"
#define PSYNC_CRYPTO_SYM_FLAG_ISDIR 1 #define PSYNC_CRYPTO_SYM_FLAG_ISDIR 1