BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
8 deletions
+53
-8
command.rb
lib/gitlab/chat_commands/command.rb
+5
-8
help.rb
lib/gitlab/chat_commands/help.rb
+28
-0
help.rb
lib/gitlab/chat_commands/presenters/help.rb
+20
-0
No files found.
lib/gitlab/chat_commands/command.rb
View file @
53846da2
...
...
@@ -18,25 +18,22 @@ module Gitlab
Gitlab
::
ChatCommands
::
Presenters
::
Access
.
new
.
access_denied
end
else
help
(
help_message
s
)
Gitlab
::
ChatCommands
::
Help
.
new
(
project
,
current_user
,
params
).
execute
(
available_command
s
)
end
end
def
match_command
match
=
nil
service
=
available_commands
.
find
do
|
klass
|
match
=
klass
.
match
(
params
[
:text
])
end
service
=
available_commands
.
find
do
|
klass
|
match
=
klass
.
match
(
params
[
:text
])
end
[
service
,
match
]
end
private
def
help_messages
available_commands
.
map
(
&
:help_message
)
end
def
available_commands
COMMANDS
.
select
do
|
klass
|
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