2 * Copyright 2011-2016, Rene Gollent, rene@gollent.com.
3 * Copyright 2012, Ingo Weinhold, ingo_weinhold@gmx.de.
4 * Distributed under the terms of the MIT License.
6 #ifndef COMMAND_LINE_USER_INTERFACE_H
7 #define COMMAND_LINE_USER_INTERFACE_H
10 #include <ObjectList.h>
13 #include "CliContext.h"
14 #include "UserInterface.h"
20 class CommandLineUserInterface
: public UserInterface
{
22 CommandLineUserInterface();
23 virtual ~CommandLineUserInterface();
25 virtual const char* ID() const;
27 virtual status_t
Init(Team
* team
,
28 UserInterfaceListener
* listener
);
30 virtual void Terminate();
31 // shut down the UI *now* -- no more user
34 virtual UserInterface
* Clone() const;
36 virtual bool IsInteractive() const;
38 virtual status_t
LoadSettings(const TeamUiSettings
* settings
);
39 virtual status_t
SaveSettings(TeamUiSettings
*& settings
) const;
41 virtual void NotifyUser(const char* title
,
43 user_notification_type type
);
44 virtual void NotifyBackgroundWorkStatus(
46 virtual int32
SynchronouslyAskUser(const char* title
,
47 const char* message
, const char* choice1
,
48 const char* choice2
, const char* choice3
);
49 virtual status_t
SynchronouslyAskUserForFile(entry_ref
* _ref
);
52 // Called by the main thread, when
53 // everything has been set up. Enters the
58 typedef BObjectList
<CommandEntry
> CommandList
;
63 friend struct HelpCommand
;
66 static status_t
_InputLoopEntry(void* data
);
67 status_t
_InputLoop();
69 status_t
_RegisterCommands();
70 bool _RegisterCommand(const BString
& name
,
72 void _ExecuteCommand(int argc
,
73 const char* const* argv
);
74 CommandEntry
* _FindCommand(const char* commandName
);
75 void _PrintHelp(const char* commandName
);
76 static int _CompareCommandEntries(
77 const CommandEntry
* command1
,
78 const CommandEntry
* command2
);
82 CommandList fCommands
;
83 sem_id fShowSemaphore
;
85 volatile bool fTerminating
;
89 #endif // COMMAND_LINE_USER_INTERFACE_H