Add --version option that shows the CryFS version and exits.
This commit is contained in:
parent
494e90bc1f
commit
5fc0b7cae8
@ -2,6 +2,7 @@ Version 0.9.9 (unreleased)
|
||||
--------------
|
||||
Improvements:
|
||||
* Add --allow-filesystem-upgrade option which will upgrade old file systems without asking the user. This will be especially helpful for GUI tools.
|
||||
* Add --version option that shows the CryFS version and exits.
|
||||
|
||||
Version 0.9.8
|
||||
--------------
|
||||
|
@ -19,7 +19,7 @@ cryfs \- cryptographic filesystem for the cloud
|
||||
[\fB\-\-\fR \fIfuse-options\fR]
|
||||
.br
|
||||
.\" show-ciphers syntax
|
||||
.B cryfs \-\-help\fR|\fB\-\-show-ciphers
|
||||
.B cryfs \-\-help\fR|\fB\-\-version\fR|\fB\-\-show-ciphers
|
||||
.
|
||||
.
|
||||
.
|
||||
@ -119,6 +119,12 @@ Show a help message containing short descriptions for all options.
|
||||
Show a list of all supported encryption ciphers.
|
||||
.
|
||||
.
|
||||
.TP
|
||||
\fB\-\-version\fR
|
||||
.
|
||||
Show the CryFS version number.
|
||||
.
|
||||
.
|
||||
.SS Encryption parameters
|
||||
.
|
||||
.TP
|
||||
|
@ -12,6 +12,7 @@ using cryfs::CryConfigConsole;
|
||||
using std::pair;
|
||||
using std::vector;
|
||||
using std::cerr;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
using std::string;
|
||||
using boost::optional;
|
||||
@ -105,6 +106,9 @@ po::variables_map Parser::_parseOptions(const vector<string> &options, const vec
|
||||
if (vm.count("show-ciphers")) {
|
||||
_showCiphersAndExit(supportedCiphers);
|
||||
}
|
||||
if (vm.count("version")) {
|
||||
_showVersionAndExit();
|
||||
}
|
||||
po::notify(vm);
|
||||
|
||||
return vm;
|
||||
@ -135,6 +139,7 @@ void Parser::_addAllowedOptions(po::options_description *desc) {
|
||||
("show-ciphers", "Show list of supported ciphers.")
|
||||
("unmount-idle", po::value<double>(), "Automatically unmount after specified number of idle minutes.")
|
||||
("logfile", po::value<string>(), "Specify the file to write log messages to. If this is not specified, log messages will go to stdout, or syslog if CryFS is running in the background.")
|
||||
("version", "Show CryFS version number")
|
||||
;
|
||||
desc->add(options);
|
||||
}
|
||||
@ -174,3 +179,8 @@ void Parser::_addPositionalOptionForBaseDir(po::options_description *desc, po::p
|
||||
<< endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
[[noreturn]] void Parser::_showVersionAndExit() {
|
||||
// no need to show version because it was already shown in the CryFS header before parsing program options
|
||||
exit(1);
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ namespace cryfs {
|
||||
boost::program_options::positional_options_description *positional);
|
||||
[[noreturn]] static void _showHelpAndExit();
|
||||
[[noreturn]] static void _showCiphersAndExit(const std::vector<std::string> &supportedCiphers);
|
||||
[[noreturn]] static void _showVersionAndExit();
|
||||
static boost::program_options::variables_map _parseOptionsOrShowHelp(const std::vector<std::string> &options, const std::vector<std::string> &supportedCiphers);
|
||||
static boost::program_options::variables_map _parseOptions(const std::vector<std::string> &options, const std::vector<std::string> &supportedCiphers);
|
||||
static void _checkValidCipher(const std::string &cipher, const std::vector<std::string> &supportedCiphers);
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include <cryfs-cli/program_options/Parser.h>
|
||||
#include <cryfs/config/CryCipher.h>
|
||||
#include <cpp-utils/pointer/unique_ref_boost_optional_gtest_workaround.h>
|
||||
#include <gitversion/gitversion.h>
|
||||
|
||||
using namespace cryfs;
|
||||
using namespace cryfs::program_options;
|
||||
@ -54,6 +55,16 @@ TEST_F(ProgramOptionsParserTest, ShowCiphers) {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
TEST_F(ProgramOptionsParserTest, Version) {
|
||||
string expected = "CryFS Version " + gitversion::VersionString();
|
||||
EXPECT_EXIT(
|
||||
parse({"./myExecutable", "--version"}),
|
||||
::testing::ExitedWithCode(0),
|
||||
expected.c_str()
|
||||
);
|
||||
}
|
||||
|
||||
TEST_F(ProgramOptionsParserTest, BaseDir_Absolute) {
|
||||
ProgramOptions options = parse({"./myExecutable", "/home/user/baseDir", "/home/user/mountDir"});
|
||||
EXPECT_EQ("/home/user/baseDir", options.baseDir());
|
||||
|
Loading…
Reference in New Issue
Block a user