KittehOrg / KittehIRCClientLib

An IRC client library in Java
https://kitteh.dev/kicl/
MIT License
146 stars 34 forks source link

Command convenience methods for all commands #118

Closed mbax closed 8 years ago

mbax commented 8 years ago

In #116 the idea of adding methods like newOperCommand to Client was brought up.

I feel the methods already provided for convenience on Channel are useful due to the potentially frequent usage. Operator commands, particularly OPER, are much more special case. Should KICL provided a new*Command in the relevant class for all commands?

Zarthus commented 8 years ago

My personal opinion: no.

Only commands that will be used should be added with convenience, the user should refer to the docs (you could provide a list of all commands) if they want to utilize KICL for it's fullest.

kashike commented 8 years ago

I say yes, only for consistency.

mbax commented 8 years ago

client.newCommand().away().message("Doot doot").execute().

public interface Client {
    // other stuff already here obviously
    class Commands {
        // constructor, set variable client
        public AwayCommand away() {
            return new AwayCommand(this.client);
        }

        public KickCommand kick(String channel) {
            return new KickCommand(this.client, channel);
        }
    }
}
mbax commented 8 years ago

Moving to 2.0 for breaking idea of migrating existing commands in Channel to such a thing too.

kashike commented 8 years ago
public interface Channel {
    class Commands {
        public KickCommand kick() {
            return new KickCommand(this.client, channel.getMessagingName());
        }

        public KickCommand kick() {
            return new KickCommand(this.client, channel);
        }
    }

    Commands newCommand();
}
public interface Client {
    // other stuff already here obviously
    class Commands {
        // constructor, set variable client
        public AwayCommand away() {
            return new AwayCommand(this.client);
        }

        public KickCommand kick(Channel channel) {
            return this.kick(channel.getMessagingName());
        }

        public KickCommand kick(String channel) {
            return new KickCommand(this.client, channel);
        }
    }

    Commands newCommand();
}

?

mbax commented 8 years ago

Something like that, yes. Thoughts?

Zarthus commented 8 years ago

that list would probably be ending up rather long, I see no problem with it but I'd definitely separate commands from client in a new file. I don't think it's the Client's job to have knowledge of all commands defined as an interface.

mbax commented 8 years ago

How many commands are there, such that it'd end up long?

mbax commented 8 years ago

I'm migrating this out of 2.0.0 because I still don't feel this is an appropriate solution.

mbax commented 8 years ago

https://github.com/KittehOrg/KittehIRCClientLib/commit/23b484e9df6fa29bce35611ad1cba770407e2dbe