-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathCommand.cpp
More file actions
33 lines (26 loc) · 937 Bytes
/
Command.cpp
File metadata and controls
33 lines (26 loc) · 937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//
// Command.cpp
// Assignment1
//
// Created by rick gessner on 10/15/18.
// Copyright © 2018 rick gessner. All rights reserved.
//
#include "Command.hpp"
#include <iostream>
Command::Command(const char* aKeyword, int aMinArgs, int aMaxArgs)
minArgs(aMinArgs), maxArgs(aMaxArgs), mKeyword(aKeyword) {}
bool Command::operator==(std::string &aKeyword) {
return !mKeyword.compare(aKeyword);
}
int Command::operator ()(std::string &anInputString) {
//first, retrieve arguments from inputString
//if you have a valid number of arguments, output the command with args
//otherwise return an error code related to the arguments
std::cout << "called " << mKeyword << " with " << anInputString << std::endl;
return 0; //would be an error code; 0=ok
}
Command& Command::describeError(float anErrorCode) {
//show a text description of the error code here...
std::cout << "some error here...";
return *this;
}