-
Notifications
You must be signed in to change notification settings - Fork 3
/
shared_external_tool_interfaces.e
executable file
·76 lines (62 loc) · 2.52 KB
/
shared_external_tool_interfaces.e
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
note
component: "Eiffel Object Modelling Framework"
description: "Abstract concept of a command set for a tool, such as Git"
keywords: "command line, external command"
author: "Thomas Beale <[email protected]>"
support: "http://www.openehr.org/issues/browse/AWB"
copyright: "Copyright (c) 2014- openEHR Foundation <http://www.openEHR.org>"
license: "Apache 2.0 License <http://www.apache.org/licenses/LICENSE-2.0.html>"
class SHARED_EXTERNAL_TOOL_INTERFACES
inherit
EXTERNAL_TOOL_DEFINITIONS
SHARED_RESOURCES
feature -- Status Report
has_tool_interface (a_tool_name: STRING): BOOLEAN
-- True if there is an interface available for `a_tool_name'
do
Result := tool_interfaces.has (a_tool_name)
end
tool_available (a_tool_name: STRING): BOOLEAN
-- True if `a_tool_name' exists on the system
do
Result := system_has_command (a_tool_name)
end
tool_supported (a_tool_name: STRING): BOOLEAN
-- True if `a_tool_name' exists on the system and has support in this interface
do
Result := system_has_command (a_tool_name) and has_tool_interface (a_tool_name)
end
feature -- Factory
create_tool_interface (a_tool_name: STRING): EXTERNAL_TOOL_INTERFACE
require
has_tool_interface (a_tool_name)
do
check attached tool_interfaces.item (a_tool_name) as att_func then
Result := att_func.item ([])
end
end
create_tool_interface_from_checkout (a_local_dir: STRING): detachable VCS_TOOL_INTERFACE
-- create the right kind of tool interface for the checkout area;
-- dont' create anything if no tool available (i.e. installed somewhere on system)
do
if is_git_clone (a_local_dir) and then tool_available (Git_tool_name) then
check attached {VCS_TOOL_INTERFACE} create_tool_interface (Git_tool_name) as att_tool_if then
Result := att_tool_if
end
Result.initialise_from_local (a_local_dir)
elseif is_svn_checkout (a_local_dir) and then tool_available (Svn_tool_name) then
check attached {VCS_TOOL_INTERFACE} create_tool_interface (Svn_tool_name) as att_tool_if then
Result := att_tool_if
end
Result.initialise_from_local (a_local_dir)
end
end
feature {NONE} -- Implementation
tool_interfaces: HASH_TABLE [FUNCTION [ANY, TUPLE, EXTERNAL_TOOL_INTERFACE], STRING]
-- table of tool
once ("PROCESS")
create Result.make (0)
Result.put (agent :GIT_TOOL_INTERFACE do create Result.make (Git_tool_name) end, Git_tool_name)
Result.put (agent :SVN_TOOL_INTERFACE do create Result.make (Svn_tool_name) end, Svn_tool_name)
end
end