Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to provide help information for bot and commands WIP #69

Merged
merged 5 commits into from
May 15, 2016

Conversation

accessd
Copy link
Member

@accessd accessd commented Apr 27, 2016

Hi @dblock!
In process now. I'd like to add ability for showing all possible commands. What do you think about it?

@dblock
Copy link
Collaborator

dblock commented Apr 27, 2016

It's a great idea, but maybe part of help? For example each command could self-document?

@accessd
Copy link
Member Author

accessd commented Apr 27, 2016

Yep, I thought about help. So, for example help shows all possible commands and then you able to ask about concrete command in format help <command>.
Command could be self-documented as far as it's possible. But what about if user have ability to add some description to his own command?

@dblock
Copy link
Collaborator

dblock commented Apr 27, 2016

Right, the author of the command could document it, maybe something like this?

module SlackRubyBot
  module Commands
    class Hi < Base
      name 'hi'
      desc 'Says hello.'
      long_desc 'When a user types "hi" the bot will reply "hello". This helps everyone stay polite.'
    end
  end
end

@accessd
Copy link
Member Author

accessd commented Apr 27, 2016

Ok, so it's optional feature and we show only documented commands?

@accessd
Copy link
Member Author

accessd commented Apr 27, 2016

I mean in list of possible commands. We can show not documented plain commands too.

@dblock
Copy link
Collaborator

dblock commented Apr 27, 2016

I say we show all and make it mandatory feature part of the help command. You can remove the help command or roll your own (we should document how) if you don't want this behavior.

@accessd
Copy link
Member Author

accessd commented Apr 27, 2016

So, we'll put the logic that checks that all the commands have documented in SlackRubyBot::Commands::Help and throw an exception if are not. Right?

You can remove the help command or roll your own

Do you mean for specific command?

@dblock
Copy link
Collaborator

dblock commented Apr 27, 2016

You can default to blank when a command isn't documented.

I mean if you want to replace the built-in Help command (that you're coding) by something else you can always make your own.

@accessd
Copy link
Member Author

accessd commented Apr 28, 2016

I think that name of the command shouldn't be blank. Others can be blank.

What about backward compatibility? User should be define all help attributes or replace built-in help command?

@dblock
Copy link
Collaborator

dblock commented Apr 28, 2016

I wouldn't worry too much about backward compatibility here. We can provide an entry in UPGRADING that explains how to do it by hand.

@accessd accessd changed the title show commands command WIP Ability to provide help information for bot and commands WIP May 3, 2016
@accessd accessd force-pushed the feature/show-commands branch 2 times, most recently from b4ee1fa to 50d9203 Compare May 3, 2016 15:05
@accessd
Copy link
Member Author

accessd commented May 3, 2016

Updated 😃
So, now you can set description for bot and commands.

How it looks:

class MarketBot < SlackRubyBot::Bot
  title 'MarketBot'
  desc 'Shows the last finance quotes'
  long_desc 'Understands commands like: How\'s AMZN today?'

slack

@@ -1,6 +1,10 @@
require 'slack-ruby-bot'

class Bot < SlackRubyBot::Bot
title 'ping'
desc 'Sends you pong.'
long_desc ''
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume we don't require this? For demo purposes maybe remove this line?

@dblock
Copy link
Collaborator

dblock commented May 3, 2016

Overall, this is great, but I still have a problem with scope. When something inherits from Commands::Base and declares 1 command it works great, but most people these days define multiple command 'foo', so we would want to allow something like this:

title 'foo'
command 'foo' do ...
end

title 'bar'
command 'bar' do ...
end

Which just means that a new title needs to reset a stack of options and add itself to an array of things and not set self.title = .... But then we're going down a rabbit hole which we already had to undo in other projects like https://github.com/ruby-grape/grape#parameters, so we should learn from that and maybe write help descriptions like so:

help do
  title 'Weather Bot'
  desc 'This bot tells you the weather.'

  command 'clouds' do
    desc 'Tells you how many clouds there're above you.'
  end

  command 'What's the weather in <city>?' do
    desc 'Tells you the weather in a <city>.'
    long_desc '...'
  end
end

What do you think?

@accessd
Copy link
Member Author

accessd commented May 3, 2016

Yeah, I see. I think it would be great. I'll try to implement it.

@accessd
Copy link
Member Author

accessd commented May 3, 2016

But may be long_desc is excess. Because I don't when show it in case command 'What's the weather in <city>?' do, for example.

@accessd accessd force-pushed the feature/show-commands branch 2 times, most recently from fc6651a to 239485b Compare May 5, 2016 18:43
@accessd
Copy link
Member Author

accessd commented May 5, 2016

updated.
how it looks now:

slack


class << self

private
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't have private class methods. You can just make this a regular method.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm learning. Thanks!

@dblock
Copy link
Collaborator

dblock commented May 6, 2016

This is great. It needs specs, documentation, CHANGELOG, etc and it will be good to go.

@accessd accessd force-pushed the feature/show-commands branch 2 times, most recently from 24bcb48 to 27a4877 Compare May 14, 2016 10:03
@accessd accessd force-pushed the feature/show-commands branch 6 times, most recently from 7a39b85 to 2a7cfd0 Compare May 14, 2016 12:11
@accessd
Copy link
Member Author

accessd commented May 14, 2016

ready. check it, please.

@dblock dblock merged commit 3002bd2 into slack-ruby:master May 15, 2016
@dblock
Copy link
Collaborator

dblock commented May 15, 2016

This is great, merged.

@dblock
Copy link
Collaborator

dblock commented Sep 24, 2016

@accessd Would appreciate a second look at #96 that now references the actual class instead of class name for picking help commands, plus some inheritance fixes.

@accessd
Copy link
Member Author

accessd commented Sep 24, 2016

@dblock #96 looks great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants