Skip to content

Commit 7abe225

Browse files
committed
Added man page.
1 parent c1e761e commit 7abe225

File tree

5 files changed

+25
-10
lines changed

5 files changed

+25
-10
lines changed

.rubocop_todo.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2020-11-22 17:19:23 UTC using RuboCop version 1.3.1.
3+
# on 2020-11-28 01:32:55 UTC using RuboCop version 1.4.2.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -49,7 +49,7 @@ Lint/SuppressedException:
4949
# ForbiddenDelimiters: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$))
5050
Naming/HeredocDelimiterNaming:
5151
Exclude:
52-
- 'lib/commands/help.rb'
52+
- 'lib/commands/man.rb'
5353
- 'lib/info.rb'
5454

5555
# Offense count: 17

lib/commands.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require_relative 'commands/base'
2-
require_relative 'commands/help'
2+
require_relative 'commands/man'
33
require_relative 'commands/pwd'
44
require_relative 'commands/ls'
55
require_relative 'commands/mkdir'
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
module SlackShellbot
22
module Commands
3-
class Help < Base
4-
command 'help'
3+
class Man < Base
4+
match(/^man$/)
55

66
HELP = <<~EOS.freeze
7-
I am your friendly Shellbot, here to help.
7+
Whoa! A bash shell in a Slack channel.
88
99
General
1010
-------
1111
12-
help - get this helpful message
12+
man - get this helpful message
1313
uname - print the operating system name
1414
whoami - print your username
1515
@@ -33,9 +33,11 @@ class Help < Base
3333
:q - quit without saving
3434
3535
EOS
36+
3637
def self.call(client, data, _match)
37-
client.say(channel: data.channel, text: [HELP, SlackShellbot::INFO].join("\n"))
38-
logger.info "HELP: #{client.owner}, user=#{data.user}"
38+
fs = client.owner.fs[data.channel]
39+
client.say(channel: data.channel, text: HELP)
40+
logger.info "MAN: #{client.owner}, #{fs}, user=#{data.user}"
3941
end
4042
end
4143
end

public/index.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</p>
1313
<p>
1414
<h3>Whoa, a bash shell inside Slack!</h3>
15-
<small>creates a rudimentary file system in every channel</small>
15+
<small>Creates a rudimentary file system in every channel.<br>Invite the bot into a channel, try <span style="font-family: Courier">man</span>, <span style="font-family: Courier">ls</span>, and other unix commands.</small>
1616
</p>
1717
<p id='messages' />
1818
<p id='register'>

spec/commands/man_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
require 'spec_helper'
2+
3+
describe SlackShellbot::Commands::Man do
4+
let(:team) { Fabricate(:team) }
5+
let(:client) { SlackShellbot::Web::Client.new(token: 'token', team: team) }
6+
let(:message_hook) { SlackShellbot::Commands::Base }
7+
context 'man' do
8+
it 'shows help' do
9+
expect(client).to receive(:say).with(channel: 'channel', text: SlackShellbot::Commands::Man::HELP)
10+
message_hook.call(client, Hashie::Mash.new(team: team, text: "man", channel: 'channel'))
11+
end
12+
end
13+
end

0 commit comments

Comments
 (0)