0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
CommandShell.h
Go to the documentation of this file.
1 /* -*- c++ -*-
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; version 3 of the
9  * License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
22 #ifndef Tools_Lib_CommandShell_h
23 #define Tools_Lib_CommandShell_h
24 
25 #include "CommandInterpreter.h"
26 #include "Notifier.h"
27 
28 #include <Common/Config.h>
29 #include <Common/Properties.h>
30 
31 #include <histedit.h>
32 
33 #include <memory>
34 #include <string>
35 
36 namespace Hypertable {
37 
38  class CommandShell {
39  public:
40  CommandShell(const std::string &prompt_str, const std::string &service_name,
42 
43  ~CommandShell();
44 
45  int run();
46 
47  bool silent() { return m_silent; }
48  bool test_mode() { return m_test_mode; }
49  void set_namespace(const String &ns) { m_namespace=ns; }
51 
52  static void add_options(PropertiesDesc &);
53 
55 
56  private:
57  char *rl_gets();
59  static const wchar_t *prompt(EditLine *el);
60 
64 
66  bool m_verbose {};
67  bool m_batch_mode {};
68  bool m_silent {};
69  bool m_test_mode {};
70  bool m_no_prompt {};
72  bool m_cont {};
73  char *m_line_read {};
74  bool m_notify {};
75  bool m_has_cmd_file {};
76  bool m_has_cmd_exec {};
78  std::string m_prompt;
79  std::wstring m_wprompt;
80  std::string m_service_name;
84 
85  EditLine *m_editline;
86  HistoryW *m_history;
87  HistEventW m_history_event;
88  TokenizerW *m_tokenizer;
89  };
90 
91  typedef std::shared_ptr<CommandShell> CommandShellPtr;
92 
94  static void init_options() {
96  }
97  };
98 
99 
100 }
101 
102 #endif // Tools_Lib_CommandShell_h
103 
static CommandShell * ms_instance
Definition: CommandShell.h:58
Interface and base of config policy.
Definition: Config.h:149
static const wchar_t * prompt(EditLine *el)
std::string String
A String is simply a typedef to std::string.
Definition: String.h:44
Program options handling.
CommandShell(const std::string &prompt_str, const std::string &service_name, CommandInterpreterPtr &, PropertiesPtr &)
CommandInterpreterPtr m_interp_ptr
Definition: CommandShell.h:61
std::string m_service_name
Definition: CommandShell.h:80
Desc & cmdline_desc(const char *usage)
A macro which definds global functions like get_bool(), get_str(), get_i16() etc. ...
Definition: Config.cc:72
std::shared_ptr< Notifier > NotifierPtr
Definition: Notifier.h:77
std::shared_ptr< Properties > PropertiesPtr
Definition: Properties.h:447
Po::options_description PropertiesDesc
Definition: Properties.h:200
TokenizerW * m_tokenizer
Definition: CommandShell.h:88
static void add_options(PropertiesDesc &)
NotifierPtr m_notifier_ptr
Definition: CommandShell.h:63
static String ms_history_file
Definition: CommandShell.h:54
std::shared_ptr< CommandInterpreter > CommandInterpreterPtr
std::shared_ptr< CommandShell > CommandShellPtr
Definition: CommandShell.h:91
Hypertable definitions
void set_namespace(const String &ns)
Definition: CommandShell.h:49
Configuration settings.
void set_line_command_mode(bool val)
Definition: CommandShell.h:50