1
// Copyright © 2017-2020 Trust Wallet.
2
//
3
// This file is part of Trust. The full Trust copyright notice, including
4
// terms governing use, modification, and redistribution, is contained in the
5
// file LICENSE at the root of the source code distribution tree.
6

7
#pragma once
8

9
#include "Buffer.h"
10
#include "Keys.h"
11
#include "Coins.h"
12
#include "Address.h"
13
#include "Util.h"
14

15
#include "Data.h"
16

17
#include <string>
18
#include <vector>
19
#include <cassert>
20
#include <iostream>
21

22
namespace TW::WalletConsole {
23

24
using namespace std;
25

26 1
class CommandExecutor {
27
protected:
28
    ostream& _out;
29
    Coins _coins;
30
    Buffer _buffer;
31
    Keys _keys;
32
    Address _address;
33
    Util _util;
34
    string _activeCoin;
35

36
public:
37
    CommandExecutor(ostream& out);
38
    void init();
39
    void executeLine(const string& line);
40

41
protected:
42
    /// Put result in res.  Return true if meaningful result is returned. 
43
    bool executeOne(const string& cmd, const vector<string>& params, string& res);
44
    void execute(const string& cmd, const vector<string>& params);
45
    static vector<string> tokenize(const string& line);
46
    static string parseLine(const string& line, vector<string>& params);
47
    bool prepareInputs(const vector<string>& p_in, vector<string>& p_out);
48
    bool setCoin(const string& coin, bool force);
49
    bool checkMinParams(const vector<string>& params, int n) const;
50
    void help() const;
51
};
52

53
} // namespace TW::WalletConsole

Read our documentation on viewing source code .

Loading