|
30 | 30 | #ifndef CLI_H_
|
31 | 31 | #define CLI_H_
|
32 | 32 |
|
33 |
| -#include <iostream> |
34 | 33 | #include <string>
|
35 | 34 | #include <vector>
|
36 | 35 | #include <memory>
|
|
44 | 43 | #include "detail/fromstring.h"
|
45 | 44 | #include "historystorage.h"
|
46 | 45 | #include "volatilehistorystorage.h"
|
| 46 | +#include <iostream> |
| 47 | +#include <utility> |
47 | 48 |
|
48 | 49 | namespace cli
|
49 | 50 | {
|
@@ -128,7 +129,7 @@ namespace cli
|
128 | 129 | ) :
|
129 | 130 | globalHistoryStorage(std::move(historyStorage)),
|
130 | 131 | rootMenu(std::move(_rootMenu)),
|
131 |
| - exitAction(_exitAction) |
| 132 | + exitAction(std::move(_exitAction)) |
132 | 133 | {
|
133 | 134 | }
|
134 | 135 |
|
@@ -191,7 +192,7 @@ namespace cli
|
191 | 192 | class Command
|
192 | 193 | {
|
193 | 194 | public:
|
194 |
| - explicit Command(const std::string& _name) : name(_name), enabled(true) {} |
| 195 | + explicit Command(std::string _name) : name(std::move(_name)), enabled(true) {} |
195 | 196 | virtual ~Command() = default;
|
196 | 197 | virtual void Enable() { enabled = true; }
|
197 | 198 | virtual void Disable() { enabled = false; }
|
@@ -313,9 +314,9 @@ namespace cli
|
313 | 314 | private:
|
314 | 315 | struct Descriptor
|
315 | 316 | {
|
316 |
| - Descriptor() {} |
317 |
| - Descriptor(const std::weak_ptr<Command>& c, const std::weak_ptr<CmdVec>& v) : |
318 |
| - cmd(c), cmds(v) |
| 317 | + Descriptor() = default; |
| 318 | + Descriptor(std::weak_ptr<Command> c, std::weak_ptr<CmdVec> v) : |
| 319 | + cmd(std::move(c)), cmds(std::move(v)) |
319 | 320 | {}
|
320 | 321 | void Enable()
|
321 | 322 | {
|
@@ -359,8 +360,8 @@ namespace cli
|
359 | 360 |
|
360 | 361 | Menu() : Command({}), parent(nullptr), description(), cmds(std::make_shared<Cmds>()) {}
|
361 | 362 |
|
362 |
| - Menu(const std::string& _name, const std::string& desc = "(menu)") : |
363 |
| - Command(_name), parent(nullptr), description(desc), cmds(std::make_shared<Cmds>()) |
| 363 | + Menu(const std::string& _name, std::string desc = "(menu)") : |
| 364 | + Command(_name), parent(nullptr), description(std::move(desc)), cmds(std::make_shared<Cmds>()) |
364 | 365 | {}
|
365 | 366 |
|
366 | 367 | template <typename F>
|
@@ -568,10 +569,10 @@ namespace cli
|
568 | 569 | VariadicFunctionCommand(
|
569 | 570 | const std::string& _name,
|
570 | 571 | F fun,
|
571 |
| - const std::string& desc, |
572 |
| - const std::vector<std::string>& parDesc |
| 572 | + std::string desc, |
| 573 | + std::vector<std::string> parDesc |
573 | 574 | )
|
574 |
| - : Command(_name), func(std::move(fun)), description(desc), parameterDesc(parDesc) |
| 575 | + : Command(_name), func(std::move(fun)), description(std::move(desc)), parameterDesc(std::move(parDesc)) |
575 | 576 | {
|
576 | 577 | }
|
577 | 578 |
|
@@ -626,10 +627,10 @@ namespace cli
|
626 | 627 | FreeformCommand(
|
627 | 628 | const std::string& _name,
|
628 | 629 | F fun,
|
629 |
| - const std::string& desc, |
630 |
| - const std::vector<std::string>& parDesc |
| 630 | + std::string desc, |
| 631 | + std::vector<std::string> parDesc |
631 | 632 | )
|
632 |
| - : Command(_name), func(std::move(fun)), description(desc), parameterDesc(parDesc) |
| 633 | + : Command(_name), func(std::move(fun)), description(std::move(desc)), parameterDesc(std::move(parDesc)) |
633 | 634 | {
|
634 | 635 | }
|
635 | 636 |
|
|
0 commit comments