mirror of
https://github.com/polybar/polybar.git
synced 2024-11-11 13:50:56 -05:00
fix(main): Exit on unrecognized positional arg
This commit is contained in:
parent
d6a34717bf
commit
13633f715d
2 changed files with 7 additions and 3 deletions
|
@ -86,7 +86,7 @@ namespace command_line {
|
|||
* Test if a positional argument is defined at given index
|
||||
*/
|
||||
bool parser::has(size_t index) const {
|
||||
return m_posargs.size() >= std::max(1_z, index);
|
||||
return m_posargs.size() > index;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -103,7 +103,7 @@ namespace command_line {
|
|||
* Get the positional argument at given index
|
||||
*/
|
||||
string parser::get(size_t index) const {
|
||||
return has(index) ? m_posargs[std::max(1_z, index) - 1] : "";
|
||||
return has(index) ? m_posargs[index] : "";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -98,7 +98,11 @@ int main(int argc, char** argv) {
|
|||
string confpath;
|
||||
|
||||
// Make sure a bar name is passed in
|
||||
if (!cli->has(1)) {
|
||||
if (!cli->has(0)) {
|
||||
cli->usage();
|
||||
return EXIT_FAILURE;
|
||||
} else if (cli->has(1)) {
|
||||
fprintf(stderr, "Unrecognized argument \"%s\"\n", cli->get(1).c_str());
|
||||
cli->usage();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue