2016-10-02 21:59:28 +02:00
|
|
|
#include "./args.h"
|
|
|
|
|
|
|
|
namespace Cli {
|
|
|
|
|
|
|
|
Args::Args() :
|
|
|
|
help(parser),
|
|
|
|
status("status", 's', "shows the status"),
|
|
|
|
log("log", 'l', "shows the Syncthing log"),
|
2016-10-02 22:16:43 +02:00
|
|
|
stop("stop", '\0', "stops Syncthing"),
|
2016-10-02 21:59:28 +02:00
|
|
|
restart("restart", '\0', "restarts Syncthing"),
|
|
|
|
rescan("rescan", 'r', "rescans the specified directories"),
|
|
|
|
rescanAll("rescan-all", '\0', "rescans all directories"),
|
|
|
|
pause("pause", '\0', "pauses the specified devices"),
|
2017-02-23 17:47:19 +01:00
|
|
|
pauseAllDevs("pause-all-devs", '\0', "pauses all devices"),
|
|
|
|
pauseAllDirs("pause-all-dirs", '\0', "pauses all directories"),
|
2016-10-02 21:59:28 +02:00
|
|
|
resume("resume", '\0', "resumes the specified devices"),
|
2017-02-23 17:47:19 +01:00
|
|
|
resumeAllDevs("resume-all-devs", '\0', "resumes all devices"),
|
|
|
|
resumeAllDirs("resume-all-dirs", '\0', "resumes all directories"),
|
2016-10-17 22:49:22 +02:00
|
|
|
waitForIdle("wait-for-idle", 'w', "waits until the specified dirs/devs are idling"),
|
2017-03-29 23:17:53 +02:00
|
|
|
pwd("pwd", 'p', "operates in the current working directory"),
|
2017-04-06 00:08:24 +02:00
|
|
|
statusPwd("status", 's', "prints the status of the current working directory"),
|
|
|
|
rescanPwd("rescan", 'r', "rescans the current working directory"),
|
|
|
|
pausePwd("pause", 'p', "pauses the current working directory"),
|
|
|
|
resumePwd("resume", '\0', "resumes the current working directory"),
|
2017-02-23 17:47:19 +01:00
|
|
|
statusDir("dir", 'd', "specifies the directoies (default is all dirs)", {"ID"}),
|
|
|
|
statusDev("dev", '\0', "specifies the devices (default is all devs)", {"ID"}),
|
|
|
|
pauseDir("dir", 'd', "specifies the directories", {"ID"}),
|
|
|
|
pauseDev("dev", '\0', "specifies the devices", {"ID"}),
|
2016-10-02 21:59:28 +02:00
|
|
|
configFile("config-file", 'f', "specifies the Syncthing config file", {"path"}),
|
|
|
|
apiKey("api-key", 'k', "specifies the API key", {"key"}),
|
|
|
|
url("url", 'u', "specifies the Syncthing URL, default is http://localhost:8080", {"URL"}),
|
|
|
|
credentials("credentials", 'c', "specifies user name and password", {"user name", "password"}),
|
|
|
|
certificate("cert", '\0', "specifies the certificate used by the Syncthing instance", {"path"})
|
|
|
|
{
|
2017-02-23 17:47:19 +01:00
|
|
|
for(Argument *arg : {&statusDir, &statusDev, &pauseDev, &pauseDir}) {
|
|
|
|
arg->setConstraints(0, -1);
|
|
|
|
}
|
|
|
|
status.setSubArguments({&statusDir, &statusDev});
|
|
|
|
waitForIdle.setSubArguments({&statusDir, &statusDev});
|
2017-04-06 00:08:24 +02:00
|
|
|
pwd.setSubArguments({&statusPwd, &rescanPwd, &pausePwd, &resumePwd});
|
2016-10-02 21:59:28 +02:00
|
|
|
|
|
|
|
rescan.setValueNames({"dir ID"});
|
|
|
|
rescan.setRequiredValueCount(-1);
|
2017-02-23 17:47:19 +01:00
|
|
|
pause.setSubArguments({&pauseDir, &pauseDev});
|
|
|
|
resume.setSubArguments({&pauseDir, &pauseDev});
|
2016-10-02 21:59:28 +02:00
|
|
|
|
2017-02-23 17:47:19 +01:00
|
|
|
parser.setMainArguments({&status, &log, &stop, &restart, &rescan, &rescanAll, &pause, &pauseAllDevs, &pauseAllDirs, &resume, &resumeAllDevs,
|
2017-03-29 23:17:53 +02:00
|
|
|
&resumeAllDirs, &waitForIdle, &pwd, &configFile, &apiKey, &url, &credentials, &certificate, &help});
|
2016-10-02 21:59:28 +02:00
|
|
|
|
|
|
|
// allow setting default values via environment
|
|
|
|
configFile.setEnvironmentVariable("SYNCTHING_CTL_CONFIG_FILE");
|
|
|
|
apiKey.setEnvironmentVariable("SYNCTHING_CTL_API_KEY");
|
|
|
|
url.setEnvironmentVariable("SYNCTHING_CTL_URL");
|
|
|
|
certificate.setEnvironmentVariable("SYNCTHING_CTL_CERTIFICATE");
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Cli
|