@@ -24,9 +24,11 @@ std::shared_ptr<RequestShutdownCommandLineOptions> RequestShutdownCommandLineOpt
24
24
{ " warm" , no_argument, 0 , ' w' },
25
25
{ " fast" , no_argument, 0 , ' f' },
26
26
{ " pre" , no_argument, 0 , ' p' }, // Requesting pre shutdown
27
+ { " help" , no_argument, 0 , ' h' },
27
28
28
29
{ " globalContext" , required_argument, 0 , ' g' },
29
30
{ " contextContig" , required_argument, 0 , ' x' },
31
+ { 0 , 0 , 0 , 0 }
30
32
};
31
33
32
34
bool optionSpecified = false ;
@@ -35,7 +37,7 @@ std::shared_ptr<RequestShutdownCommandLineOptions> RequestShutdownCommandLineOpt
35
37
{
36
38
int option_index = 0 ;
37
39
38
- int c = getopt_long (argc, argv, " cwfpg:x:" , long_options, &option_index);
40
+ int c = getopt_long (argc, argv, " cwfpg:x:h " , long_options, &option_index);
39
41
40
42
if (c == -1 )
41
43
break ;
@@ -68,7 +70,11 @@ std::shared_ptr<RequestShutdownCommandLineOptions> RequestShutdownCommandLineOpt
68
70
69
71
case ' x' :
70
72
options->m_contextConfig = std::string (optarg );
71
- break ;
73
+ break
74
+ ;
75
+ case ' h' :
76
+ printUsage ();
77
+ exit (EXIT_FAILURE);
72
78
73
79
default :
74
80
SWSS_LOG_ERROR (" getopt failure" );
@@ -92,19 +98,24 @@ void RequestShutdownCommandLineOptionsParser::printUsage()
92
98
{
93
99
SWSS_LOG_ENTER ();
94
100
95
- std::cout << " Usage: syncd_request_shutdown [-w] [--warm] [-p] [--pre] [-c] [--cold] [-f] [--fast] [-g idx] [-x contextConfig]" << std::endl;
101
+ std::cout << " Usage: syncd_request_shutdown [-w] [--warm] [-p] [--pre] [-c] [--cold] [-f] [--fast] [-g idx] [-x contextConfig] [-h] [--help] " << std::endl;
96
102
97
103
std::cerr << std::endl;
98
104
99
105
std::cerr << " Shutdown option must be specified" << std::endl;
100
106
std::cerr << " ---------------------------------" << std::endl;
101
- std::cerr << " --warm -w for warm restart" << std::endl;
102
- std::cerr << " --pre -p for warm pre-shutdown" << std::endl;
103
- std::cerr << " --cold -c for cold restart" << std::endl;
104
- std::cerr << " --fast -f for fast restart" << std::endl;
105
- std::cerr << std::endl;
106
- std::cout << " --globalContext -g" << std::endl;
107
- std::cout << " Global context index to load from context config file" << std::endl;
108
- std::cout << " --contextConfig -x" << std::endl;
109
- std::cout << " Context configuration file" << std::endl;
107
+ std::cerr << " -w --warm" << std::endl;
108
+ std::cerr << " For warm restart" << std::endl;
109
+ std::cerr << " -p --pre" << std::endl;
110
+ std::cerr << " For warm pre-shutdown" << std::endl;
111
+ std::cerr << " -c --cold" << std::endl;
112
+ std::cerr << " For cold restart" << std::endl;
113
+ std::cerr << " -f --fast" << std::endl;
114
+ std::cerr << " For fast restart" << std::endl;
115
+ std::cout << " -g --globalContext " << std::endl;
116
+ std::cout << " Global context index to load from context config file" << std::endl;
117
+ std::cout << " -x --contextConfig" << std::endl;
118
+ std::cout << " Context configuration file" << std::endl;
119
+ std::cout << " -h --help" << std::endl;
120
+ std::cout << " Print usege" << std::endl;
110
121
}
0 commit comments