#endif /* OPENSSL_NO_TRACE */
static char *help_argv[] = { "help", NULL };
+static char *version_argv[] = { "version", NULL };
int main(int argc, char *argv[])
{
const char *fname;
ARGS arg;
int global_help = 0;
+ int global_version = 0;
int ret = 0;
arg.argv = NULL;
global_help = argc > 1
&& (strcmp(argv[1], "-help") == 0 || strcmp(argv[1], "--help") == 0
|| strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--h") == 0);
+ global_version = argc > 1
+ && (strcmp(argv[1], "-version") == 0 || strcmp(argv[1], "--version") == 0
+ || strcmp(argv[1], "-v") == 0 || strcmp(argv[1], "--v") == 0);
+
argc--;
argv++;
- opt_appname(argc == 1 || global_help ? "help" : argv[0]);
+ opt_appname(argc == 1 || global_help ? "help" : global_version ? "version" : argv[0]);
} else {
argv[0] = pname;
}
- /* If there's a command, run with that, otherwise "help". */
- ret = argc == 0 || global_help
- ? do_cmd(prog, 1, help_argv)
- : do_cmd(prog, argc, argv);
+ /*
+ * If there's no command, assume "help". If there's an override for help
+ * or version run those, otherwise run the command given.
+ */
+ ret = (argc == 0) || global_help
+ ? do_cmd(prog, 1, help_argv)
+ : global_version
+ ? do_cmd(prog, 1, version_argv)
+ : do_cmd(prog, argc, argv);
end:
OPENSSL_free(default_config_file);
{NULL}
};
-
int help_main(int argc, char **argv)
{
FUNCTION *fp;
B<openssl> B<no->I<XXX> [ I<options> ]
+B<openssl> B<-help> | B<-version>
+
=head1 DESCRIPTION
OpenSSL is a cryptography toolkit implementing the Secure Sockets Layer (SSL)
Details of which options are available depend on the specific command.
This section describes some common options with common behavior.
-=head2 Common Options
+=head2 Program Options
+
+These options can be specified without a command specified to get help
+or version information.
=over 4
=item B<-help>
Provides a terse summary of all options.
+For more detailed information, each command supports a B<-help> option.
+Accepts B<--help> as well.
+
+=item B<-version>
+
+Provides a terse summary of the B<openssl> program version.
+For more detailed information see L<openssl-version(1)>.
+Accepts B<--version> as well.
+
+=back
+
+=head2 Common Options
+
+=over 4
+
+=item B<-help>
+
If an option takes an argument, the "type" of argument is also given.
=item B<-->
setup("test_app");
-plan tests => 5;
+plan tests => 7;
ok(run(app(["openssl"])),
"Run openssl app with no args");
ok(run(app(["openssl", "--help"])),
"Run openssl app with --help");
+
+ok(run(app(["openssl", "-version"])),
+ "Run openssl app with -version");
+
+ok(run(app(["openssl", "--version"])),
+ "Run openssl app with --version");