Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
53846da2
Commit
53846da2
authored
Jan 11, 2017
by
Z.J. van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add help command
parent
746f4720
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
8 deletions
+53
-8
lib/gitlab/chat_commands/command.rb
lib/gitlab/chat_commands/command.rb
+5
-8
lib/gitlab/chat_commands/help.rb
lib/gitlab/chat_commands/help.rb
+28
-0
lib/gitlab/chat_commands/presenters/help.rb
lib/gitlab/chat_commands/presenters/help.rb
+20
-0
No files found.
lib/gitlab/chat_commands/command.rb
View file @
53846da2
...
@@ -18,13 +18,14 @@ module Gitlab
...
@@ -18,13 +18,14 @@ module Gitlab
Gitlab
::
ChatCommands
::
Presenters
::
Access
.
new
.
access_denied
Gitlab
::
ChatCommands
::
Presenters
::
Access
.
new
.
access_denied
end
end
else
else
help
(
help_message
s
)
Gitlab
::
ChatCommands
::
Help
.
new
(
project
,
current_user
,
params
).
execute
(
available_command
s
)
end
end
end
end
def
match_command
def
match_command
match
=
nil
match
=
nil
service
=
available_commands
.
find
do
|
klass
|
service
=
available_commands
.
find
do
|
klass
|
match
=
klass
.
match
(
params
[
:text
])
match
=
klass
.
match
(
params
[
:text
])
end
end
...
@@ -33,10 +34,6 @@ module Gitlab
...
@@ -33,10 +34,6 @@ module Gitlab
private
private
def
help_messages
available_commands
.
map
(
&
:help_message
)
end
def
available_commands
def
available_commands
COMMANDS
.
select
do
|
klass
|
COMMANDS
.
select
do
|
klass
|
klass
.
available?
(
project
)
klass
.
available?
(
project
)
...
...
lib/gitlab/chat_commands/help.rb
0 → 100644
View file @
53846da2
module
Gitlab
module
ChatCommands
class
Help
<
BaseCommand
# This class has to be used last, as it always matches. It has to match
# because other commands were not triggered and we want to show the help
# command
def
self
.
match
(
_text
)
true
end
def
self
.
help_message
'help'
end
def
self
.
allowed?
(
_project
,
_user
)
true
end
def
execute
(
commands
)
Gitlab
::
ChatCommands
::
Presenters
::
Help
.
new
(
commands
).
present
(
trigger
)
end
def
trigger
params
[
:command
]
end
end
end
end
lib/gitlab/chat_commands/presenters/help.rb
0 → 100644
View file @
53846da2
module
Gitlab::ChatCommands::Presenters
class
Help
<
Gitlab
::
ChatCommands
::
Presenters
::
Base
def
present
(
trigger
)
message
=
if
@resource
.
none?
"No commands available :thinking_face:"
else
header_with_list
(
"Available commands"
,
full_commands
(
trigger
))
end
ephemeral_response
(
text:
message
)
end
private
def
full_commands
(
trigger
)
@resource
.
map
{
|
command
|
"
#{
trigger
}
#{
command
.
help_message
}
"
}
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment