Fix pldmd verbosity command line argument
This commit would attempt to fix the command line argument --verbose.
The fact that verbose option requires an argument 0 or 1 is not
particularly intuitive and a documented OpenBMC anti-pattern.
https://github.com/openbmc/docs/blob/master/anti-patterns.md#non-standard-debug-application-options-and-logging
Resolves : https://github.com/openbmc/pldm/issues/7
Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com>
Change-Id: I50d82ce492bd815b589627d3713b1a7fc1db997b
diff --git a/pldmd/pldmd.cpp b/pldmd/pldmd.cpp
index 1e7cd15..dc0a2bb 100644
--- a/pldmd/pldmd.cpp
+++ b/pldmd/pldmd.cpp
@@ -147,37 +147,25 @@
{
std::cerr << "Usage: pldmd [options]\n";
std::cerr << "Options:\n";
- std::cerr
- << " --verbose=<0/1> 0 - Disable verbosity, 1 - Enable verbosity\n";
- std::cerr << "Defaulted settings: --verbose=0 \n";
+ std::cerr << " [--verbose] - would enable verbosity\n";
}
int main(int argc, char** argv)
{
bool verbose = false;
- static struct option long_options[] = {
- {"verbose", required_argument, 0, 'v'}, {0, 0, 0, 0}};
+ static struct option long_options[] = {{"verbose", no_argument, 0, 'v'},
+ {0, 0, 0, 0}};
- auto argflag = getopt_long(argc, argv, "v:", long_options, nullptr);
+ auto argflag = getopt_long(argc, argv, "v", long_options, nullptr);
switch (argflag)
{
case 'v':
- switch (std::stoi(optarg))
- {
- case 0:
- verbose = false;
- break;
- case 1:
- verbose = true;
- break;
- default:
- optionUsage();
- exit(EXIT_FAILURE);
- }
+ verbose = true;
break;
case -1:
break;
default:
+ optionUsage();
exit(EXIT_FAILURE);
}
diff --git a/pldmd/service_files/pldmd.service b/pldmd/service_files/pldmd.service
index 4eaa706..4972822 100644
--- a/pldmd/service_files/pldmd.service
+++ b/pldmd/service_files/pldmd.service
@@ -7,8 +7,8 @@
Restart=always
Type=dbus
BusName=xyz.openbmc_project.PLDM
-EnvironmentFile=/etc/default/pldm_verbosity
-ExecStart=/usr/bin/pldmd --verbose $VERBOSE
+EnvironmentFile=-/etc/default/pldmd
+ExecStart=/usr/bin/pldmd $PLDMD_ARGS
[Install]
WantedBy=multi-user.target
diff --git a/pldmd/verbosity/verbosity b/pldmd/verbosity/verbosity
deleted file mode 100644
index 45cf9bf..0000000
--- a/pldmd/verbosity/verbosity
+++ /dev/null
@@ -1 +0,0 @@
-VERBOSE=@PLDM_VERBOSITY@