-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b2a1429
commit dd15163
Showing
5 changed files
with
53 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include "echo.hpp" | ||
|
||
int main(int argc, const char **argv) | ||
{ | ||
auto command = EchoCommand(); | ||
return command.run(argc, argv); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#pragma once | ||
|
||
#include <base.hpp> | ||
#include <standard.hpp> | ||
|
||
class EchoCommand : public BaseCommand | ||
{ | ||
public: | ||
using BaseCommand::run; | ||
|
||
EchoCommand() : BaseCommand("echo") {} | ||
|
||
bool accept_any_arguments() override | ||
{ | ||
return true; | ||
} | ||
|
||
int run(const ParseResult &arguments) override | ||
{ | ||
if (arguments.original.size() > 1) // Skip first argument | ||
{ | ||
for (unsigned i = 1; i < arguments.original.size() - 1; i++) | ||
{ | ||
std::cout << arguments.original[i] << " "; | ||
} | ||
std::cout << arguments.original.back(); | ||
} | ||
|
||
std::cout << std::endl; | ||
return 0; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters