refactor(command_line): Cleanup
This commit is contained in:
parent
683ce7acc6
commit
5d5542169b
@ -37,9 +37,9 @@ namespace command_line {
|
||||
class parser {
|
||||
public:
|
||||
using make_type = unique_ptr<parser>;
|
||||
static make_type make(string scriptname, const options& opts);
|
||||
static make_type make(string&& scriptname, const options&& opts);
|
||||
|
||||
explicit parser(const string& synopsis, const options& opts) : m_synopsis(synopsis), m_opts(opts) {}
|
||||
explicit parser(string&& synopsis, const options&& opts);
|
||||
|
||||
void usage() const;
|
||||
|
||||
@ -59,7 +59,7 @@ namespace command_line {
|
||||
|
||||
private:
|
||||
string m_synopsis;
|
||||
options m_opts;
|
||||
const options m_opts;
|
||||
values m_optvalues;
|
||||
bool m_skipnext = false;
|
||||
};
|
||||
|
@ -10,10 +10,17 @@ POLYBAR_NS
|
||||
/**
|
||||
* Create instance
|
||||
*/
|
||||
cliparser::make_type cliparser::make(string scriptname, const clioptions& opts) {
|
||||
return factory_util::unique<cliparser>("Usage: " + scriptname + " bar_name [OPTION...]", opts);
|
||||
cliparser::make_type cliparser::make(string&& scriptname, const clioptions&& opts) {
|
||||
return factory_util::unique<cliparser>(
|
||||
"Usage: " + scriptname + " bar_name [OPTION...]", forward<decltype(opts)>(opts));
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct parser
|
||||
*/
|
||||
cliparser::parser(string&& synopsis, const options&& opts)
|
||||
: m_synopsis(forward<decltype(synopsis)>(synopsis)), m_opts(forward<decltype(opts)>(opts)) {}
|
||||
|
||||
/**
|
||||
* Print application usage message
|
||||
*/
|
||||
|
10
src/main.cpp
10
src/main.cpp
@ -13,9 +13,6 @@
|
||||
|
||||
using namespace polybar;
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
struct exit_success {};
|
||||
struct exit_failure {};
|
||||
|
||||
@ -70,8 +67,7 @@ int main(int argc, char** argv) {
|
||||
string scriptname{argv[0]};
|
||||
vector<string> args{argv + 1, argv + argc};
|
||||
|
||||
cliparser::make_type cli{cliparser::make(move(scriptname), opts)};
|
||||
|
||||
cliparser::make_type cli{cliparser::make(move(scriptname), move(opts))};
|
||||
cli->process_input(args);
|
||||
|
||||
if (cli->has("quiet")) {
|
||||
@ -112,7 +108,7 @@ int main(int argc, char** argv) {
|
||||
// Dump requested data
|
||||
//==================================================
|
||||
if (cli->has("dump")) {
|
||||
cout << conf.get<string>(conf.bar_section(), cli->get("dump")) << endl;
|
||||
std::cout << conf.get<string>(conf.bar_section(), cli->get("dump")) << std::endl;
|
||||
throw exit_success{};
|
||||
}
|
||||
|
||||
@ -133,7 +129,7 @@ int main(int argc, char** argv) {
|
||||
ctrl = controller::make(move(path_confwatch), enable_ipc, cli->has("stdout"));
|
||||
|
||||
if (cli->has("print-wmname")) {
|
||||
cout << ctrl->opts().wmname << endl;
|
||||
std::cout << ctrl->opts().wmname << std::endl;
|
||||
throw exit_success{};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user