From 8d4baaa1b43e96ca586c4007fc7cc8e6e24c13c4 Mon Sep 17 00:00:00 2001 From: Levi Neely <141506390+lneely@users.noreply.github.com> Date: Sat, 14 Dec 2024 11:56:30 +0100 Subject: [PATCH] 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 --- control_tools.cpp | 24 ++++++++++++------------ pclsync/pcloudcrypto.c | 3 +-- pclsync/pcloudcrypto.h | 4 ++-- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/control_tools.cpp b/control_tools.cpp index 4dd8b85..0612dcb 100644 --- a/control_tools.cpp +++ b/control_tools.cpp @@ -332,10 +332,10 @@ void process_commands() { // crypto subcommands auto start_crypto_cmd = crypto_cmd->add_subcommand("start", "Start crypto"); - std::string crypto_arg; - start_crypto_cmd->add_option("arg", crypto_arg, "Crypto argument") + std::string start_crypto_pwd; + start_crypto_cmd->add_option("password", start_crypto_pwd, "Crypto password") ->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); @@ -345,22 +345,22 @@ void process_commands() { ->callback(list_sync_folders); auto sync_add_cmd = sync_cmd->add_subcommand("add", "Add sync folder"); - std::string syncadd_arg; - sync_add_cmd->add_option("arg", syncadd_arg, "Paths")->required(); + std::string syncadd_lpath, syncadd_rpath; + 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([&] { - auto [lpath, rpath] = split_paths(syncadd_arg.c_str()); - add_sync_folder(lpath, rpath); + add_sync_folder(syncadd_lpath, syncadd_rpath); }); auto sync_remove_cmd = - sync_cmd->add_subcommand("remove", "Remove sync folder")->alias("rm"); - std::string syncrm_arg; - sync_remove_cmd->add_option("arg", syncrm_arg, "Path")->required(); - sync_remove_cmd->callback([&] { remove_sync_folder(syncrm_arg.c_str()); }); + sync_cmd->add_subcommand("remove", "Remove sync folder (use ls to get folder ID)")->alias("rm"); + std::string syncrm_fid; + sync_remove_cmd->add_option("folderid", syncrm_fid, "Folder ID")->required(); + sync_remove_cmd->callback([&] { remove_sync_folder(syncrm_fid.c_str()); }); // command loop while (true) { - std::cout << "> "; + std::cout << "pcloud> "; std::string line; if (!std::getline(std::cin, line)) break; diff --git a/pclsync/pcloudcrypto.c b/pclsync/pcloudcrypto.c index f2936ca..c35238e 100644 --- a/pclsync/pcloudcrypto.c +++ b/pclsync/pcloudcrypto.c @@ -42,15 +42,14 @@ #include "pcache.h" #include "pcloudcrypto.h" #include "pcrypto.h" -#include "pdiff.h" #include "pfileops.h" #include "pfolder.h" +#include "pfs.h" #include "plibs.h" #include "pmemlock.h" #include "pnetlibs.h" #include "psettings.h" #include "pssl.h" -#include "pstatus.h" #include #define PSYNC_CRYPTO_API_ERR_INTERNAL -511 diff --git a/pclsync/pcloudcrypto.h b/pclsync/pcloudcrypto.h index ffbec43..1bef73c 100644 --- a/pclsync/pcloudcrypto.h +++ b/pclsync/pcloudcrypto.h @@ -33,9 +33,9 @@ #define _PCLOUD_CRYPTO_H #include "papi.h" -#include "pcompiler.h" #include "pcrypto.h" -#include "pfs.h" +#include "pfsfolder.h" +#include "psynclib.h" #define PSYNC_CRYPTO_SYM_FLAG_ISDIR 1