[thin_delta] -h/--help
This commit is contained in:
parent
87fa6dc079
commit
83f2cce597
@ -6,3 +6,24 @@ Feature: thin_delta
|
||||
Scenario: print version (--version flag)
|
||||
When I run `thin_delta --version`
|
||||
Then it should pass with version
|
||||
|
||||
Scenario: print help
|
||||
When I run `thin_delta --help`
|
||||
Then it should pass with:
|
||||
|
||||
"""
|
||||
Usage: thin_delta [options]
|
||||
Options:
|
||||
{-h|--help}
|
||||
{-V|--version}
|
||||
"""
|
||||
|
||||
Scenario: print help
|
||||
When I run `thin_delta -h`
|
||||
Then it should pass with:
|
||||
"""
|
||||
Usage: thin_delta [options]
|
||||
Options:
|
||||
{-h|--help}
|
||||
{-V|--version}
|
||||
"""
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <getopt.h>
|
||||
#include <iostream>
|
||||
#include <libgen.h>
|
||||
|
||||
#include "version.h"
|
||||
|
||||
@ -7,16 +8,32 @@ using namespace std;
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
||||
namespace {
|
||||
void usage(ostream &out, string const &cmd) {
|
||||
out << "Usage: " << cmd << " [options]" << endl
|
||||
<< "Options:" << endl
|
||||
<< " {-h|--help}" << endl
|
||||
<< " {-V|--version}" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
char const shortopts[] = "V";
|
||||
char const shortopts[] = "hV";
|
||||
option const longopts[] = {
|
||||
{ "version", no_argument, NULL, 'V'}
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
{ "version", no_argument, NULL, 'V' }
|
||||
};
|
||||
|
||||
while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1) {
|
||||
switch (c) {
|
||||
case 'h':
|
||||
usage(cout, basename(argv[0]));
|
||||
return 0;
|
||||
|
||||
case 'V':
|
||||
cout << THIN_PROVISIONING_TOOLS_VERSION << endl;
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user