summaryrefslogtreecommitdiffstats
blob: f05568456ee57ba5a5428d02e5a0eda208a9e5c7 (plain)
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
34
35
36
37
38
/*
 * Copyright (c) 2013 Remko Tronçon
 * Licensed under the GNU General Public License.
 * See the COPYING file for more information.
 */

#include <Sluift/StandardTerminal.h>

#include <boost/optional.hpp>
#include <iostream>
#include <stdexcept>

using namespace Swift;

StandardTerminal::StandardTerminal() {
}

StandardTerminal::~StandardTerminal() {
}

void StandardTerminal::printError(const std::string& message) {
	std::cout << message << std::endl;
}

boost::optional<std::string> StandardTerminal::readLine(const std::string& prompt) {
	std::cout << prompt << std::flush;
	std::string input;
	if (!std::getline(std::cin, input)) {
		if (std::cin.eof()) {
			return boost::optional<std::string>();
		}
		throw std::runtime_error("Input error");
	}
	return input;
}

void StandardTerminal::addToHistory(const std::string&) {
}