mirror of
https://github.com/AGWA/git-crypt.git
synced 2025-12-07 13:20:34 -08:00
Add 'git-crypt version' command
This commit is contained in:
@@ -78,6 +78,11 @@ static void print_usage (std::ostream& out)
|
||||
out << "See 'git-crypt help COMMAND' for more information on a specific command." << std::endl;
|
||||
}
|
||||
|
||||
static void print_version (std::ostream& out)
|
||||
{
|
||||
out << "git-crypt " << VERSION << std::endl;
|
||||
}
|
||||
|
||||
static bool help_for_command (const char* command, std::ostream& out)
|
||||
{
|
||||
if (std::strcmp(command, "init") == 0) {
|
||||
@@ -121,6 +126,12 @@ static int help (int argc, const char** argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int version (int argc, const char** argv)
|
||||
{
|
||||
print_version(std::cout);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, const char** argv)
|
||||
try {
|
||||
@@ -141,6 +152,9 @@ try {
|
||||
if (std::strcmp(argv[arg_index], "--help") == 0) {
|
||||
print_usage(std::clog);
|
||||
return 0;
|
||||
} else if (std::strcmp(argv[arg_index], "--version") == 0) {
|
||||
print_version(std::clog);
|
||||
return 0;
|
||||
} else if (std::strcmp(argv[arg_index], "--") == 0) {
|
||||
++arg_index;
|
||||
break;
|
||||
@@ -171,6 +185,9 @@ try {
|
||||
if (std::strcmp(command, "help") == 0) {
|
||||
return help(argc, argv);
|
||||
}
|
||||
if (std::strcmp(command, "version") == 0) {
|
||||
return version(argc, argv);
|
||||
}
|
||||
if (std::strcmp(command, "init") == 0) {
|
||||
return init(argc, argv);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
#ifndef GIT_CRYPT_GIT_CRYPT_HPP
|
||||
#define GIT_CRYPT_GIT_CRYPT_HPP
|
||||
|
||||
#define VERSION "0.4.0"
|
||||
|
||||
extern const char* argv0; // initialized in main() to argv[0]
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user